Skip to content

API: raise on unsupported dtype instead of silently swapping #49285

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 10 commits into from
Nov 8, 2022

Conversation

jbrockmendel
Copy link
Member

  • closes #xxxx (Replace xxxx with the GitHub issue number)
  • Tests added and passed if fixing a bug or adding a new feature
  • All code checks passed.
  • Added type annotations to new arguments/methods/functions.
  • Added an entry in the latest doc/source/whatsnew/vX.X.X.rst file if fixing a bug or adding a new feature.

Looks like ATM the DataFrame case raises bc it goes through a different path, while the Series case does not.

mentioned in (but this does not close) #48979

@mroeschke mroeschke added Dtype Conversions Unexpected or buggy dtype conversions Non-Nano datetime64/timedelta64 with non-nanosecond resolution labels Oct 25, 2022
@mroeschke mroeschke added this to the 2.0 milestone Oct 25, 2022

*New behavior*:

In [5]: pd.Series(["2016-01-01"], dtype="datetime64[s]")
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be in a .. ipython:: python block

Copy link
Member Author

Choose a reason for hiding this comment

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

its still not happy here

<<<-------------------------------------------------------------------------
WARNING: 
>>>-------------------------------------------------------------------------
Exception in /home/runner/work/pandas/pandas/doc/source/whatsnew/v2.0.0.rst at block ending on line 161
Specify :okexcept: as an option in the ipython:: block to suppress this message
  Cell In [6], line 1
    TypeError: dtype=datetime64[D] is not supported. Supported resolutions are 's', 'ms', 'us', and 'ns'
                                                               ^
SyntaxError: invalid syntax

Copy link
Contributor

Choose a reason for hiding this comment

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

remote the prompts e.g.

pd.Series(.....)

Copy link
Member

Choose a reason for hiding this comment

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

This section should just be

*New behavior*:

.. ipython:: python

    pd.Series(["2016-01-01"], dtype="datetime64[s]")

Copy link
Member Author

Choose a reason for hiding this comment

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

That did it, thanks

@jbrockmendel
Copy link
Member Author

@jreback little help with the docbuild? (also thoughts on the API change?)

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.

suggestion on doc build. api change lgtm.


*New behavior*:

In [5]: pd.Series(["2016-01-01"], dtype="datetime64[s]")
Copy link
Contributor

Choose a reason for hiding this comment

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

remote the prompts e.g.

pd.Series(.....)

:okexcept:

In [6]: pd.Series(["2016-01-01"], dtype="datetime64[D]")

Copy link
Contributor

Choose a reason for hiding this comment

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

remove the prompts

Copy link
Member Author

Choose a reason for hiding this comment

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

still getting errors

@jbrockmendel
Copy link
Member Author

@jreback still struggling with the docbuild

@mroeschke mroeschke merged commit 5a36b5f into pandas-dev:main Nov 8, 2022
@mroeschke
Copy link
Member

Thanks @jbrockmendel

@jbrockmendel
Copy link
Member Author

sweet! the only big constructor-behavior-matching one left is #49348

@jbrockmendel jbrockmendel deleted the api-ensure_nanosecond_dtype branch November 8, 2022 20:35
phofl pushed a commit to phofl/pandas that referenced this pull request Nov 9, 2022
…dev#49285)

* API: raise on unsupported dtype instead of silently swapping

* lint fixup

* ipython blocks

* okexcept

* troubleshoto doc

* jeffs suggestion

* troubleshoot docbuild
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 Non-Nano datetime64/timedelta64 with non-nanosecond resolution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants