File tree 2 files changed +24
-3
lines changed
2 files changed +24
-3
lines changed Original file line number Diff line number Diff line change 31
31
npt ,
32
32
)
33
33
from pandas .util ._decorators import cache_readonly
34
+ from pandas .util ._exceptions import find_stack_level
34
35
from pandas .util ._validators import validate_bool_kwarg
35
36
36
37
from pandas .core .dtypes .cast import (
@@ -268,8 +269,19 @@ def make_block_same_class(
268
269
placement = self ._mgr_locs
269
270
270
271
if values .dtype .kind in ["m" , "M" ]:
271
- # TODO: remove this once fastparquet has stopped relying on it
272
- values = ensure_wrapped_if_datetimelike (values )
272
+
273
+ new_values = ensure_wrapped_if_datetimelike (values )
274
+ if new_values is not values :
275
+ # TODO(2.0): remove once fastparquet has stopped relying on it
276
+ warnings .warn (
277
+ "In a future version, Block.make_block_same_class will "
278
+ "assume that datetime64 and timedelta64 ndarrays have "
279
+ "already been cast to DatetimeArray and TimedeltaArray, "
280
+ "respectively." ,
281
+ DeprecationWarning ,
282
+ stacklevel = find_stack_level (),
283
+ )
284
+ values = new_values
273
285
274
286
# We assume maybe_coerce_values has already been called
275
287
return type (self )(values , placement = placement , ndim = self .ndim )
Original file line number Diff line number Diff line change 27
27
)
28
28
from pandas .errors import PerformanceWarning
29
29
from pandas .util ._decorators import cache_readonly
30
+ from pandas .util ._exceptions import find_stack_level
30
31
from pandas .util ._validators import validate_bool_kwarg
31
32
32
33
from pandas .core .dtypes .cast import infer_dtype_from_scalar
@@ -907,7 +908,15 @@ def __init__(
907
908
f"number of axes ({ self .ndim } )"
908
909
)
909
910
if isinstance (block , DatetimeTZBlock ) and block .values .ndim == 1 :
910
- # TODO: remove once fastparquet no longer needs this
911
+ # TODO(2.0): remove once fastparquet no longer needs this
912
+ warnings .warn (
913
+ "In a future version, the BlockManager constructor "
914
+ "will assume that a DatetimeTZBlock with block.ndim==2 "
915
+ "has block.values.ndim == 2." ,
916
+ DeprecationWarning ,
917
+ stacklevel = find_stack_level (),
918
+ )
919
+
911
920
# error: Incompatible types in assignment (expression has type
912
921
# "Union[ExtensionArray, ndarray]", variable has type
913
922
# "DatetimeArray")
You can’t perform that action at this time.
0 commit comments