Skip to content

BUG: DataFrame groupby values of a tz-aware datetime column returns underlying datetime integer #12085

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
iyer opened this issue Jan 18, 2016 · 1 comment
Labels
Duplicate Report Duplicate issue or pull request
Milestone

Comments

@iyer
Copy link

iyer commented Jan 18, 2016

I am running into an issue which appears only in pandas 0.17 or higher where tz aware datetime columns get converted into their integer values by a groupby operation

## This is an issue when timestamps are TZ aware
dts = [pd.Timestamp('20160101', tz='UTC'), pd.Timestamp('20160102', tz='UTC')]
values = [1,2]
df = pd.DataFrame({'DATE':dts, 'VALUE':values})
df.groupby('VALUE').DATE.max()
Out[1]: 
VALUE
1    1451606400000000000
2    1451692800000000000
Name: DATE, dtype: int64

## This is not an issue when tmestamps are not TZ aware
dts = [pd.Timestamp('20160101'), pd.Timestamp('20160102')]
values = [1,2]
df = pd.DataFrame({'DATE':dts, 'VALUE':values})
df.groupby('VALUE').DATE.max()
Out[2]: 
VALUE
1   2016-01-01
2   2016-01-02
Name: DATE, dtype: datetime64[ns]

## Version information
pd.show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 3.5.1.final.0
python-bits: 64
OS: Linux
OS-release: 2.6.32-431.11.2.el6.x86_64
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8

pandas: 0.17.1
nose: 1.3.7
pip: 7.1.2
setuptools: 19.1.1
Cython: 0.23.4
numpy: 1.10.2
scipy: 0.16.1
statsmodels: None
IPython: 4.0.1
sphinx: 1.3.1
patsy: 0.4.0
dateutil: 2.4.2
pytz: 2015.7
blosc: None
bottleneck: 1.0.0
tables: 3.2.2
numexpr: 2.4.4
matplotlib: 1.5.0
openpyxl: 2.2.6
xlrd: 0.9.4
xlwt: 1.0.0
xlsxwriter: 0.7.7
lxml: 3.5.0
bs4: 4.4.1
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.10
pymysql: None
psycopg2: None
Jinja2: None
@jorisvandenbossche
Copy link
Member

Thanks for the report!
This has been fixed in master by #11672 in the meantime.

@jorisvandenbossche jorisvandenbossche added the Duplicate Report Duplicate issue or pull request label Jan 18, 2016
@jorisvandenbossche jorisvandenbossche added this to the 0.18.0 milestone Jan 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate Report Duplicate issue or pull request
Projects
None yet
Development

No branches or pull requests

2 participants