Skip to content

groupby() changes values of pandas.Timestamp (pandas 0.15.2) #9788

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ghost opened this issue Apr 2, 2015 · 1 comment
Closed

groupby() changes values of pandas.Timestamp (pandas 0.15.2) #9788

ghost opened this issue Apr 2, 2015 · 1 comment
Labels
Bug Compat pandas objects compatability with Numpy or Python functions Datetime Datetime data dtype Groupby

Comments

@ghost
Copy link

ghost commented Apr 2, 2015

import datetime as dt; import pandas as pd
d2 = dt.datetime(2015, 4, 2, 12, 23, 12, 567000)
df = pd.DataFrame([['Bar', d2]], columns=['name', 'date'])
df2 = df.sort('date').groupby('name').last().reset_index()

df2 is

name date
0 Bar 2015-04-02 12:23:12.567000064

i.e. 64 nanoseconds were added to the timestamp. The amounts added seem to be always the powers of 2, perhaps it is caused by some internal conversion to double?

@jreback
Copy link
Contributor

jreback commented Apr 2, 2015

this was fixed in 0.16.0, see #9311, #6620

In [1]: import datetime as dt; import pandas as pd

In [2]: d2 = dt.datetime(2015, 4, 2, 12, 23, 12, 567000)

In [3]: df = pd.DataFrame([['Bar', d2]], columns=['name', 'date'])

In [4]: df2 = df.sort('date').groupby('name').last().reset_index()

In [5]: df2
Out[5]: 
  name                       date
0  Bar 2015-04-02 12:23:12.567000

In [6]: df2.iloc[0,1]
Out[6]: Timestamp('2015-04-02 12:23:12.567000')

In [7]: df2.iloc[0,1].value
Out[7]: 1427977392567000000

@jreback jreback closed this as completed Apr 2, 2015
@jreback jreback added Bug Groupby Compat pandas objects compatability with Numpy or Python functions Datetime Datetime data dtype labels Apr 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Compat pandas objects compatability with Numpy or Python functions Datetime Datetime data dtype Groupby
Projects
None yet
Development

No branches or pull requests

1 participant