Skip to content

ENH: preserve non-nano DTA/TDA in Index/Series/DataFrame #47230

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 7 commits into from
Jun 15, 2022

Conversation

jbrockmendel
Copy link
Member

Continue to cast non-nano ndarrays, but if a user goes out of there way to create a non-nano DTA/TDA, preserve it in the other constructors.

@jbrockmendel
Copy link
Member Author

cc @datapythonista

@datapythonista
Copy link
Member

Looks really cool.

Not sure if for the tests I'd compare to the literal of the dtype we expect. We're testing that the type of the array are preserved. This could be tested in general (not sure if it is), but feels a bit strange that this is done in the tests specific to non-nano, instead of making sure the dtype is the non-nano we want. Not important, just sharing, if you like this approach better, is fine with me. I guess we're testing the dtype of the array elsewhere already.

@jreback jreback added the Non-Nano datetime64/timedelta64 with non-nanosecond resolution label Jun 5, 2022
@@ -537,15 +537,16 @@ def treat_as_nested(data) -> bool:
# ---------------------------------------------------------------------


def _prep_ndarray(values, copy: bool = True) -> np.ndarray:
def _prep_ndarray(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe rename to prep_array_like or similar?

Copy link
Member

@mroeschke mroeschke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fairly good. Just needs a rebase

@mroeschke mroeschke added this to the 1.5 milestone Jun 15, 2022
@mroeschke mroeschke merged commit f600fd4 into pandas-dev:main Jun 15, 2022
@mroeschke
Copy link
Member

Thanks @jbrockmendel

@jbrockmendel jbrockmendel deleted the nano-allow-dta branch June 15, 2022 16:44
yehoshuadimarsky pushed a commit to yehoshuadimarsky/pandas that referenced this pull request Jul 13, 2022
…47230)

* ENH: preserve non-nano DTA/TDA in Index/Series/DataFrame

* tighten xfail

* _prep_ndarray->_prep_ndarraylike

* xfail non-strict
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Non-Nano datetime64/timedelta64 with non-nanosecond resolution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants