-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
mroeschke
merged 10 commits into
pandas-dev:main
from
jbrockmendel:api-ensure_nanosecond_dtype
Nov 8, 2022
Merged
Changes from 3 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6f5bdfc
API: raise on unsupported dtype instead of silently swapping
jbrockmendel 5cbdcd9
lint fixup
jbrockmendel a20b0d2
ipython blocks
jbrockmendel 371d08e
okexcept
jbrockmendel 6a152e2
troubleshoto doc
jbrockmendel cbccf76
Merge branch 'main' into api-ensure_nanosecond_dtype
jbrockmendel ff8a3ee
jeffs suggestion
jbrockmendel d58c35e
Merge branch 'main' into api-ensure_nanosecond_dtype
jbrockmendel 98a7f7e
troubleshoot docbuild
jbrockmendel 37829cb
troubleshoot docbuild
jbrockmendel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,6 +99,52 @@ notable_bug_fix2 | |
Backwards incompatible API changes | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
.. _whatsnew_200.api_breaking.unsupported_datetimelike_dtype_arg: | ||
|
||
Construction with datetime64 or timedelta64 dtype with unsupported resolution | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
In past versions, when constructing a :class:`Series` or :class:`DataFrame` and | ||
passing a "datetime64" or "timedelta64" dtype with unsupported resolution | ||
(i.e. anything other than "ns"), pandas would silently replace the given dtype | ||
with its nanosecond analogue: | ||
|
||
*Previous behavior*: | ||
|
||
.. code-block:: ipython | ||
|
||
In [5]: pd.Series(["2016-01-01"], dtype="datetime64[s]") | ||
Out[5]: | ||
0 2016-01-01 | ||
dtype: datetime64[ns] | ||
|
||
In [6]: pd.Series(["2016-01-01"], dtype="datetime64[D]") | ||
Out[6]: | ||
0 2016-01-01 | ||
dtype: datetime64[ns] | ||
|
||
In pandas 2.0 we support resolutions "s", "ms", "us", and "ns". When passing | ||
a supported dtype (e.g. "datetime64[s]"), the result now has exactly | ||
the requested dtype: | ||
|
||
*New behavior*: | ||
|
||
.. ipython:: python | ||
|
||
In [5]: pd.Series(["2016-01-01"], dtype="datetime64[s]") | ||
Out[5]: | ||
0 2016-01-01 | ||
dtype: datetime64[s] | ||
|
||
With an un-supported dtype, pandas now raises instead of silently swapping in | ||
a supported dtype: | ||
|
||
*New behavior*: | ||
|
||
.. ipython:: python | ||
|
||
mroeschke marked this conversation as resolved.
Show resolved
Hide resolved
|
||
In [6]: pd.Series(["2016-01-01"], dtype="datetime64[D]") | ||
TypeError: dtype=datetime64[D] is not supported. Supported resolutions are 's', 'ms', 'us', and 'ns' | ||
jbrockmendel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove the prompts There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. still getting errors |
||
.. _whatsnew_200.api_breaking.deps: | ||
|
||
Increased minimum versions for dependencies | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
blockThere was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That did it, thanks