Skip to content

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

Merged
merged 10 commits into from
Jul 11, 2023
Merged
Prev Previous commit
Next Next commit
Updating warning message based on reviewer recommendations.
  • Loading branch information
rmhowe425 committed Jun 30, 2023
commit 2553d323fe23212c05e1063c726c7765c25a14b8
4 changes: 2 additions & 2 deletions pandas/core/construction.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,8 @@ def array(

elif lib.is_np_dtype(dtype, "mM"):
warnings.warn(
r"datetime64 and timedelta64 dtypes with 'm' and 'h' resolutions "
r"are deprecated.Supported resolutions are 's', 'ms','us', and 'ns'. "
r"Deprecating unsupported datetime64 and timedelta64 dtype resolutions. "
Copy link
Member

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

r"Supported resolutions are 's', 'ms','us', and 'ns'. "
r"In future releases resolutions will be cast to the closest "
r"supported unit.",
FutureWarning,
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/arrays/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ def test_dt64_array():
for unit in dtype_unit_lst:
dtype_var = np.dtype(unit)
msg = (
r"datetime64 and timedelta64 dtypes with 'm' and 'h' resolutions "
r"are deprecated.Supported resolutions are 's', 'ms','us', and 'ns'. "
r"Deprecating unsupported datetime64 and timedelta64 dtype resolutions. "
r"Supported resolutions are 's', 'ms','us', and 'ns'. "
r"In future releases resolutions will be cast to the closest "
r"supported unit."
)
Expand Down