Skip to content

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

Merged
merged 11 commits into from
Feb 20, 2024

Conversation

mroeschke
Copy link
Member

xref #52459, #54818

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)
Copy link
Member Author

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)?

Copy link
Member

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

Copy link
Member Author

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

Copy link
Member

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?

Copy link
Member Author

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

@mroeschke mroeschke added this to the 3.0 milestone Feb 16, 2024
@mroeschke
Copy link
Member Author

Going to merge this one. Can follow up if needed

@mroeschke mroeschke merged commit 0f17277 into pandas-dev:main Feb 20, 2024
@mroeschke mroeschke deleted the rm/misc branch February 20, 2024 01:21
jmarintur pushed a commit to jmarintur/pandas that referenced this pull request Feb 26, 2024
…andas-dev#57425)

* Enforce shift with freq and fill_value

* Enforce to_pydatetime change

* Change doc example

* Use to_numpy

* Use _values

* Fix doctest
@lamdang2k
Copy link
Contributor

Going to merge this one. Can follow up if needed

I am opening a PR #57469 to add future warning when calling to_pytimedelta function, but here it seems that you changed the return type to Series and removed all warning-related imports. Do you want me to do the same thing for to_pytimedelta?

pmhatre1 pushed a commit to pmhatre1/pandas-pmhatre1 that referenced this pull request May 7, 2024
…andas-dev#57425)

* Enforce shift with freq and fill_value

* Enforce to_pydatetime change

* Change doc example

* Use to_numpy

* Use _values

* Fix doctest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants