Skip to content

DEPR: warn on checks retained for fastparquet #44193

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 6 commits into from
Oct 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions pandas/core/internals/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
npt,
)
from pandas.util._decorators import cache_readonly
from pandas.util._exceptions import find_stack_level
from pandas.util._validators import validate_bool_kwarg

from pandas.core.dtypes.cast import (
Expand Down Expand Up @@ -268,8 +269,19 @@ def make_block_same_class(
placement = self._mgr_locs

if values.dtype.kind in ["m", "M"]:
# TODO: remove this once fastparquet has stopped relying on it
values = ensure_wrapped_if_datetimelike(values)

new_values = ensure_wrapped_if_datetimelike(values)
if new_values is not values:
# TODO(2.0): remove once fastparquet has stopped relying on it
warnings.warn(
"In a future version, Block.make_block_same_class will "
"assume that datetime64 and timedelta64 ndarrays have "
"already been cast to DatetimeArray and TimedeltaArray, "
"respectively.",
DeprecationWarning,
stacklevel=find_stack_level(),
)
values = new_values

# We assume maybe_coerce_values has already been called
return type(self)(values, placement=placement, ndim=self.ndim)
Expand Down
11 changes: 10 additions & 1 deletion pandas/core/internals/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
)
from pandas.errors import PerformanceWarning
from pandas.util._decorators import cache_readonly
from pandas.util._exceptions import find_stack_level
from pandas.util._validators import validate_bool_kwarg

from pandas.core.dtypes.cast import infer_dtype_from_scalar
Expand Down Expand Up @@ -907,7 +908,15 @@ def __init__(
f"number of axes ({self.ndim})"
)
if isinstance(block, DatetimeTZBlock) and block.values.ndim == 1:
# TODO: remove once fastparquet no longer needs this
# TODO(2.0): remove once fastparquet no longer needs this
warnings.warn(
"In a future version, the BlockManager constructor "
"will assume that a DatetimeTZBlock with block.ndim==2 "
"has block.values.ndim == 2.",
DeprecationWarning,
stacklevel=find_stack_level(),
)

# error: Incompatible types in assignment (expression has type
# "Union[ExtensionArray, ndarray]", variable has type
# "DatetimeArray")
Expand Down