Skip to content

Commit

Permalink
I had a hack where I defaulted using get_supported_reso. But new pandas
Browse files Browse the repository at this point in the history
also uses get_supported_reso when doing constructor with existing dtype.
This is missing things up. Only run the conversion if dtype is not good.
This only matters for [s]
  • Loading branch information
dalejung committed Feb 25, 2024
1 parent 156620e commit f01ae20
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pandas/core/construction.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,11 @@ def ensure_wrapped_if_datetimelike(arr):
if arr.dtype.kind == "M":
from pandas.core.arrays import DatetimeArray

dtype = get_supported_dtype(arr.dtype)
dtype = arr.dtype
# get_supported_type is hacked to return [ms] instead of [s]
# I dont want this to change.
if not is_supported_dtype(dtype):
dtype = get_supported_dtype(dtype)
return DatetimeArray._from_sequence(arr, dtype=dtype)

elif arr.dtype.kind == "m":
Expand Down

0 comments on commit f01ae20

Please sign in to comment.