Skip to content

Series does not upconvert datetimes to datetime64 #2809

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
dalejung opened this issue Feb 7, 2013 · 4 comments
Closed

Series does not upconvert datetimes to datetime64 #2809

dalejung opened this issue Feb 7, 2013 · 4 comments
Labels
Milestone

Comments

@dalejung
Copy link
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?

@jreback
Copy link
Contributor

jreback commented Feb 7, 2013

yes...see #2752 (not merged yet

@jreback
Copy link
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]

@dalejung
Copy link
Contributor Author

dalejung commented Feb 7, 2013

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

@wesm
Copy link
Member

wesm commented Feb 10, 2013

this is all set now that the PR is merged

@wesm wesm closed this as completed Feb 10, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants