-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
CLN: shift with freq and fill_value, to_pydatetime returning Series #57425
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
Conversation
pandas/io/sql.py
Outdated
warnings.filterwarnings("ignore", category=FutureWarning) | ||
# GH#52459 to_pydatetime will return Index[object] | ||
d = np.asarray(ser.dt.to_pydatetime(), dtype=object) | ||
d = ser.dt.to_pydatetime().to_numpy(dtype=object) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@phofl what's the way to make this writable later on (d[mask] = None
below)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is
ser.dt.to_pydatetime()
ever not backed by a NumPy array? If it's always a NumPy array I would just do
ser.dt.to_pydatetime()._values
Otherwise you can do
d.flags.writeable = True, but this is a bit tricky, because this won't work if d was initially a PyArrow array
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this branch, ser
was backed by ArrowExtensionArray
so it's initially a pyarrow array
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But the result of to_pydatetime is always backed by numpy, correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah OK yes it is
Going to merge this one. Can follow up if needed |
…andas-dev#57425) * Enforce shift with freq and fill_value * Enforce to_pydatetime change * Change doc example * Use to_numpy * Use _values * Fix doctest
I am opening a PR #57469 to add future warning when calling |
…andas-dev#57425) * Enforce shift with freq and fill_value * Enforce to_pydatetime change * Change doc example * Use to_numpy * Use _values * Fix doctest
xref #52459, #54818