-
Notifications
You must be signed in to change notification settings - Fork 927
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
Fix to_pandas
writable bug for datetime
and timedelta
types
#17913
base: branch-25.04
Are you sure you want to change the base?
Conversation
Curious how #17743 as a bug affects subsequent operations (i.e. is this a bug we really need to worry about?)
|
It's not serious. But AFAIK it is because |
Yeah so I'm curious what subsequent issue a user would run into if a |
This is the user-facing case I'm talking about: In [1]: import pandas as pd
i
In [2]: i = pd.Index([1, 2, 3], dtype="datetime64[ns]")
In [4]: i.to_numpy()
Out[4]:
array(['1970-01-01T00:00:00.000000001', '1970-01-01T00:00:00.000000002',
'1970-01-01T00:00:00.000000003'], dtype='datetime64[ns]')
In [5]: x = i.to_numpy()
In [6]: x[0] = 1
In [7]: x
Out[7]:
array(['1970-01-01T00:00:00.000000001', '1970-01-01T00:00:00.000000002',
'1970-01-01T00:00:00.000000003'], dtype='datetime64[ns]')
In [8]: x[0] = 2
In [9]: x
Out[9]:
array(['1970-01-01T00:00:00.000000002', '1970-01-01T00:00:00.000000002',
'1970-01-01T00:00:00.000000003'], dtype='datetime64[ns]')
In [10]: import cudf
In [11]: i = cudf.Index([1, 2, 3], dtype="datetime64[ns]")
In [13]: x = i.to_pandas().to_numpy()
In [14]: x
Out[14]:
array(['1970-01-01T00:00:00.000000001', '1970-01-01T00:00:00.000000002',
'1970-01-01T00:00:00.000000003'], dtype='datetime64[ns]')
In [15]: x[0] = 2
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[15], line 1
----> 1 x[0] = 2
ValueError: assignment destination is read-only |
Description
Fixes: #17743
This PR fixes writable flag for numpy arrays. This bug is only specific to these two types.
Checklist