-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
DEPR: Deprecate use of un-supported numpy dt64/td64 dtype for pandas.array #53817
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
Conversation
@jbrockmendel PR is ready for inspection |
pandas/core/construction.py
Outdated
warnings.warn( | ||
r"dt/td64 dtypes with 'm' and 'h' resolutions are deprecated." | ||
r"Supported resolutions are 's', 'ms','us', and 'ns'. " | ||
r"In future releases, 'm' and 'h' resolutions will be cast to the closest " |
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.
dont specify "m" and "h", since that leaves out others and it isnt worth listing all of them
pandas/core/construction.py
Outdated
@@ -379,6 +381,16 @@ def array( | |||
): | |||
return TimedeltaArray._from_sequence(data, dtype=dtype, copy=copy) | |||
|
|||
elif lib.is_np_dtype(dtype, "mM"): | |||
warnings.warn( | |||
r"dt/td64 dtypes with 'm' and 'h' resolutions are deprecated." |
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.
pls write out datetime64 and timedelta64
@jbrockmendel PR has been updated. Pinging on green |
1 similar comment
@jbrockmendel PR has been updated. Pinging on green |
pandas/core/construction.py
Outdated
@@ -379,6 +381,16 @@ def array( | |||
): | |||
return TimedeltaArray._from_sequence(data, dtype=dtype, copy=copy) | |||
|
|||
elif lib.is_np_dtype(dtype, "mM"): | |||
warnings.warn( | |||
r"Deprecating unsupported datetime64 and timedelta64 dtype resolutions. " |
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.
the first sentence here is awkward. Maybe "datetime64 and timedelta64 dtypes with resolutions other than ... are deprecated."
If they pass an unsupported dtype, we should raise, not silently cast
@jbrockmendel PR has been updated. Pinging on green |
pandas/core/construction.py
Outdated
r"datetime64 and timedelta64 dtype resolutions other than " | ||
r"'s', 'ms','us', and 'ns' are deprecated. " | ||
r"In future releases passing unsupported resolutions will " | ||
r"raise an exception. ", |
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.
typo trailing whitespace
pandas/core/construction.py
Outdated
elif lib.is_np_dtype(dtype, "mM"): | ||
warnings.warn( | ||
r"datetime64 and timedelta64 dtype resolutions other than " | ||
r"'s', 'ms','us', and 'ns' are deprecated. " |
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.
missing space between ms and us
@jbrockmendel PR has been updated. Pinging on green |
@mroeschke worth nitpicking wording any further? |
pandas/tests/arrays/test_array.py
Outdated
@@ -28,6 +29,22 @@ | |||
) | |||
|
|||
|
|||
def test_dt64_array(): | |||
# PR 53817 | |||
dtype_unit_lst = ["M8[h]", "M8[m]", "m8[h]", "M8[m]"] |
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.
Nit: Could you use @pytest.mark.parameterize
here?
@mroeschke PR ready for inspection. Looks like unit test |
Thanks @rmhowe425 |
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.