Skip to content

first/last converts datetime into float #14104

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
pkch opened this issue Aug 28, 2016 · 1 comment
Closed

first/last converts datetime into float #14104

pkch opened this issue Aug 28, 2016 · 1 comment
Labels
Dtype Conversions Unexpected or buggy dtype conversions Duplicate Report Duplicate issue or pull request Groupby

Comments

@pkch
Copy link

pkch commented Aug 28, 2016

Code Sample, a copy-pastable example if possible

import pandas as pd
df = pd.DataFrame({'a': [1, 1, 2, 2], 'b': pd.to_datetime(['a', 'a', '12-23-2015', '12-24-2015'],
                  errors='coerce')})
df.groupby('a').b.first().dtype 

Expected Output

last line is supposed to show datetime64[ns] but it actually is float64
this only happens when the entire group has NaT datetime

output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 3.5.1.final.0
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 94 Stepping 3, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None

pandas: 0.18.1
nose: 1.3.7
pip: 8.1.2
setuptools: 25.0.0
Cython: 0.24.1
numpy: 1.11.0
scipy: 0.17.0
statsmodels: 0.6.1
xarray: None
IPython: 5.0.0
sphinx: None
patsy: 0.4.1
dateutil: 2.5.3
pytz: 2016.4
blosc: None
bottleneck: None
tables: 3.2.3
numexpr: 2.5.2
matplotlib: 1.5.1
openpyxl: 2.3.5
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: 0.9.2
apiclient: 1.5.0
sqlalchemy: 1.0.14
pymysql: None
psycopg2: 2.6.2 (dt dec pq3 ext lo64)
jinja2: 2.8
boto: None
pandas_datareader: None

@jreback
Copy link
Contributor

jreback commented Aug 28, 2016

In [9]: df = pd.DataFrame({'a': [1, 1, 2, 2], 'b': pd.to_datetime(['a', 'a', '12-23-2015', '12-24-2015'],
   ...:                   errors='coerce')})
   ...: df.groupby('a').b.first()
   ...: 
Out[9]: 
a
1          NaT
2   2015-12-23
Name: b, dtype: datetime64[ns]

dupe of #12821, fixed by #12941 in master/0.19.0 (soon)

@jreback jreback closed this as completed Aug 28, 2016
@jreback jreback added Groupby Dtype Conversions Unexpected or buggy dtype conversions Duplicate Report Duplicate issue or pull request labels Aug 28, 2016
@jreback jreback added this to the No action milestone Aug 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dtype Conversions Unexpected or buggy dtype conversions Duplicate Report Duplicate issue or pull request Groupby
Projects
None yet
Development

No branches or pull requests

2 participants