-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DataFrame.values not a 2D-array when constructed from timezone-aware datetimes #13407
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
This must be shortcutting on the 1-d case in lcd_types. If you have an additional column it will work.
Note that using |
This statement is non-sensical, as numpy barley understands timezones. And an
|
Agreed; I did not phrase that properly. What I meant is that some operations on a pandas dataframe, such as |
Spent a long time debugging this today. It is very surprising to have As a workaround, I believe users can use |
When a DataFrame column is constructed from timezone-aware datetime objects, its
values
attribute returns apandas.DatetimeIndex
instead of a 2D numpy array. This is problematic because the datetime index does not support all operations that a numpy array does.Code Sample, a copy-pastable example if possible
Also,
print df.values
returnsDatetimeIndex(['2015-01-01'], dtype='datetime64[ns, UTC]', freq=None)
.Expected Output
The
df.dropna
call should be a no-op.Compare this to the case when constructed using
df['Time'] = [datetime.datetime(2015,1,1)]
. In that case,df.dropna
works as expected, anddf.values
isarray([['2014-12-31T16:00:00.000000000-0800']], dtype='datetime64[ns]')
.output of
pd.show_versions()
The text was updated successfully, but these errors were encountered: