Skip to content

Conversation

@jbrockmendel
Copy link
Member

  • closes #xxxx
  • tests added / passed
  • Ensure all linting tests pass, see here for how to run them
  • whatsnew entry

This makes it feasible to share some of the SetitemCastingEquivalents tests.

@jbrockmendel jbrockmendel changed the title Bug dtlike view BUG: DTA/TDA/PA/Series/Index.view with datetimelike Feb 13, 2021
if isinstance(dtype, (np.dtype, ExtensionDtype)) and needs_i8_conversion(
dtype
):
if dtype.kind == "m" and dtype != "m8[ns]":
Copy link
Contributor

Choose a reason for hiding this comment

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

you can handle all m and M types via this branch?

Copy link
Member Author

Choose a reason for hiding this comment

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

L757-L759 is for non-nano td64. L754-L765 handles all td64, dt64, dt64tz, and perioddtype

Copy link
Contributor

Choose a reason for hiding this comment

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

i think this could use a little more commentary here (similar to what you did on the datetimelike astype), pls catch in a followon

@jreback jreback added Dtype Conversions Unexpected or buggy dtype conversions Index Related to the Index class or subclasses labels Feb 15, 2021
Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

small comment, other lgtm.

if dtype is None or dtype is self.dtype:
return type(self)(self._ndarray, dtype=self.dtype)

if isinstance(dtype, type):
Copy link
Contributor

Choose a reason for hiding this comment

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

i think make this clear that M8[ns] (or really M8[s]) or whatever will hit here, but a tz-aware / pandas dtype will pass thru. yes after i read it i get it, but in 3 months no-one will remember.

Copy link
Member Author

Choose a reason for hiding this comment

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

fleshing out the comment bc its pretty weird. this line isnt catching np.dtype, its catching type, e.g. we get here with dtype=np.ndarray

Copy link
Member Author

Choose a reason for hiding this comment

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

updated + green

@jreback jreback added this to the 1.3 milestone Feb 17, 2021
Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

comment for followon

if isinstance(dtype, (np.dtype, ExtensionDtype)) and needs_i8_conversion(
dtype
):
if dtype.kind == "m" and dtype != "m8[ns]":
Copy link
Contributor

Choose a reason for hiding this comment

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

i think this could use a little more commentary here (similar to what you did on the datetimelike astype), pls catch in a followon

@jreback jreback merged commit 8d2a57e into pandas-dev:master Feb 21, 2021
@jbrockmendel jbrockmendel deleted the bug-dtlike-view branch February 21, 2021 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Dtype Conversions Unexpected or buggy dtype conversions Index Related to the Index class or subclasses

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants