Skip to content

BUG: recognize M8[ns, tzstr] #33885

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 6 commits into from
May 9, 2020

Conversation

jbrockmendel
Copy link
Member

  • closes #xxxx
  • tests added / passed
  • passes black pandas
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff
  • whatsnew entry

ATM dtype == "M8[ns, UTC]" fails while dtype == "datetime64[ns, UTC]" succeeds

@jorisvandenbossche
Copy link
Member

Is this needed to support? (what's the use case?)
M8 is a numpy short-hand name, but tz-aware dtype is not a numpy dtype.

@jreback jreback added the Dtype Conversions Unexpected or buggy dtype conversions label Apr 30, 2020
@jreback jreback added this to the 1.1 milestone Apr 30, 2020
@jreback
Copy link
Contributor

jreback commented Apr 30, 2020

lgtm.

Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

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

see comment

@jreback
Copy link
Contributor

jreback commented Apr 30, 2020

see comment

I find this ok, all we are asserting here is that datetime64==M8 which is true

@jbrockmendel
Copy link
Member Author

Is this needed to support? (what's the use case?)

needed? No. convenient? yes.

Until recently there as a test that checked dtype == "M8[ns, US/Eastern]" that would have failed if it wasn't missing the "assert".

@jorisvandenbossche
Copy link
Member

What is the convenience? Just less typing?

@jbrockmendel
Copy link
Member Author

What is the convenience? Just less typing?

Sure. Or maybe "lease surprise" is more accurate. e.g. is_dtype_equal(dtpye, "M8[ns, US/Eastern]") is True ATM while dtype == "M8[ns, US/Eastern]" is False

@jorisvandenbossche
Copy link
Member

jorisvandenbossche commented Apr 30, 2020

OK, but then it is fixing a bug, not providing something for convenience.

Eg, it seems that pd.Series([1, 2, 3]).astype("M8[ns, UTC]") already works. Then of course .dtype == "M8[ns, UTC]" should also work.
Do you know if it is tested that astype / pandas_dtype(..) works with this notation? If not, can you add a test for that?

@jbrockmendel
Copy link
Member Author

If not, can you add a test for that?

added

@jorisvandenbossche jorisvandenbossche merged commit ffc06f1 into pandas-dev:master May 9, 2020
@jbrockmendel jbrockmendel deleted the bug-m8tz branch May 9, 2020 21:38
rhshadrach pushed a commit to rhshadrach/pandas that referenced this pull request May 10, 2020
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants