Skip to content

Commit 90d02bd

Browse files
authored
DEPR: warn on checks retained for fastparquet (#44193)
1 parent f312cd9 commit 90d02bd

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

pandas/core/internals/blocks.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
npt,
3232
)
3333
from pandas.util._decorators import cache_readonly
34+
from pandas.util._exceptions import find_stack_level
3435
from pandas.util._validators import validate_bool_kwarg
3536

3637
from pandas.core.dtypes.cast import (
@@ -268,8 +269,19 @@ def make_block_same_class(
268269
placement = self._mgr_locs
269270

270271
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
273285

274286
# We assume maybe_coerce_values has already been called
275287
return type(self)(values, placement=placement, ndim=self.ndim)

pandas/core/internals/managers.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
)
2828
from pandas.errors import PerformanceWarning
2929
from pandas.util._decorators import cache_readonly
30+
from pandas.util._exceptions import find_stack_level
3031
from pandas.util._validators import validate_bool_kwarg
3132

3233
from pandas.core.dtypes.cast import infer_dtype_from_scalar
@@ -907,7 +908,15 @@ def __init__(
907908
f"number of axes ({self.ndim})"
908909
)
909910
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+
911920
# error: Incompatible types in assignment (expression has type
912921
# "Union[ExtensionArray, ndarray]", variable has type
913922
# "DatetimeArray")

0 commit comments

Comments
 (0)