-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
ENH: Series Creation Does Not Intelligently Handle datetime.date #4338
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
Comments
there is nothing wrong with OTOH maybe should just do this conversion ..... and your dtype in 89 will just not work; its not a valid dtype (well in 0.11 it causes subtle issues), in 0.12 I think this will raise (but'll I'll add this as an enhancement issue) |
Why do you think that it should be passed in as Numpy theoretically supports this notion with time units: http://docs.scipy.org/doc/numpy-dev/reference/arrays.datetime.html#datetime-units |
Here is perhaps a cleaner example. I do think that auto conversion COULD be performed: pd.DataFrame([[date(2012,1,1)]]).dtypes
Out[14]:
0 object
dtype: object
pd.DataFrame([[datetime.combine(date(2012,1,1), time(0,0,0))]]).dtypes
Out[15]:
0 datetime64[ns]
dtype: object |
You can put something together for 0.14 if you want |
Sounds good. I imagine this should not be too hard.
|
I know @jreback has had a pretty good sense of what we want to support for |
Is this still active? I'm hitting this in our work - loading a set of In [75]:
series=pd.Series(range(5), index=[datetime.date.today() + datetime.timedelta(i) for i in range(5)])
series
Out[75]:
2015-10-23 0
2015-10-24 1
2015-10-25 2
2015-10-26 3
2015-10-27 4
dtype: int64
In [76]:
series.index
Out[76]:
Index([2015-10-23, 2015-10-24, 2015-10-25, 2015-10-26, 2015-10-27], dtype='object') Replacing In [81]:
series=pd.Series(range(5), index=[datetime.datetime.today() + datetime.timedelta(i) for i in range(5)])
series
Out[81]:
2015-10-23 20:39:36.077137 0
2015-10-24 20:39:36.077156 1
2015-10-25 20:39:36.077169 2
2015-10-26 20:39:36.077174 3
2015-10-27 20:39:36.077178 4
dtype: int64
In [82]:
series.index
series.index
Out[82]:
DatetimeIndex(['2015-10-23 20:39:36.077137', '2015-10-24 20:39:36.077156',
'2015-10-25 20:39:36.077169', '2015-10-26 20:39:36.077174',
'2015-10-27 20:39:36.077178'],
dtype='datetime64[ns]', freq=None) |
handling It is not on the priority list, though you are welcome to take a look. |
I don't think we should auto-convert If the user wants datetimes now, then they have |
For example:
works as expected.
However:
create a Series of type object rather than datetime64.
You can get the desired effect:
The text was updated successfully, but these errors were encountered: