Series does not upconvert datetimes to datetime64 #2809

Closed
dalejung opened this Issue Feb 7, 2013 · 4 comments

Comments

Projects
None yet
3 participants
Contributor

dalejung commented Feb 7, 2013

import pandas as pd
ind = pd.date_range(start="2000-01-01", freq="D", periods=10)
datetimes = [ts.to_pydatetime() for ts in ind]

datetime_s = pd.Series(datetimes)
datetime_s.dtype
# object
df = pd.DataFrame({'datetime_s':datetime_s})
print df.dtypes
#datetime64

Shouldn't Series upconvert to datetime64 since the DataFrame columns do?

Contributor

jreback commented Feb 7, 2013

yes...see #2752 (not merged yet

Contributor

jreback commented Feb 7, 2013

In [11]: pd.Series(datetimes)
Out[11]: 
0   2000-01-01 00:00:00
1   2000-01-02 00:00:00
2   2000-01-03 00:00:00
3   2000-01-04 00:00:00
4   2000-01-05 00:00:00
5   2000-01-06 00:00:00
6   2000-01-07 00:00:00
7   2000-01-08 00:00:00
8   2000-01-09 00:00:00
9   2000-01-10 00:00:00

In [12]: pd.Series(datetimes).dtype
Out[12]: dtype('datetime64[ns]')''

In [13]: pd.DataFrame({'datetime_s' : datetimes}).dtypes
Out[13]: datetime_s    datetime64[ns]

Contributor

dalejung commented Feb 7, 2013

ooh, sweet. Didn't see the PR. Well, now it gets to close more bugs!

Owner

wesm commented Feb 10, 2013

this is all set now that the PR is merged

wesm closed this Feb 10, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment