|
59 | 59 | is_string_dtype,
|
60 | 60 | )
|
61 | 61 | from pandas.core.dtypes.dtypes import (
|
62 |
| - CategoricalDtype, |
63 | 62 | ExtensionDtype,
|
64 | 63 | PandasDtype,
|
65 | 64 | PeriodDtype,
|
@@ -175,18 +174,6 @@ def _can_hold_na(self) -> bool:
|
175 | 174 | return dtype.kind not in ["b", "i", "u"]
|
176 | 175 | return dtype._can_hold_na
|
177 | 176 |
|
178 |
| - @final |
179 |
| - @cache_readonly |
180 |
| - def is_categorical(self) -> bool: |
181 |
| - warnings.warn( |
182 |
| - "Block.is_categorical is deprecated and will be removed in a " |
183 |
| - "future version. Use isinstance(block.values, Categorical) " |
184 |
| - "instead. See https://github.com/pandas-dev/pandas/issues/40226", |
185 |
| - DeprecationWarning, |
186 |
| - stacklevel=find_stack_level(), |
187 |
| - ) |
188 |
| - return isinstance(self.values, Categorical) |
189 |
| - |
190 | 177 | @final
|
191 | 178 | @property
|
192 | 179 | def is_bool(self) -> bool:
|
@@ -240,24 +227,11 @@ def make_block_same_class(
|
240 | 227 | self, values, placement: BlockPlacement | None = None
|
241 | 228 | ) -> Block:
|
242 | 229 | """Wrap given values in a block of same type as self."""
|
| 230 | + # Pre-2.0 we called ensure_wrapped_if_datetimelike because fastparquet |
| 231 | + # relied on it, as of 2.0 the caller is responsible for this. |
243 | 232 | if placement is None:
|
244 | 233 | placement = self._mgr_locs
|
245 | 234 |
|
246 |
| - if values.dtype.kind in ["m", "M"]: |
247 |
| - |
248 |
| - new_values = ensure_wrapped_if_datetimelike(values) |
249 |
| - if new_values is not values: |
250 |
| - # TODO(2.0): remove once fastparquet has stopped relying on it |
251 |
| - warnings.warn( |
252 |
| - "In a future version, Block.make_block_same_class will " |
253 |
| - "assume that datetime64 and timedelta64 ndarrays have " |
254 |
| - "already been cast to DatetimeArray and TimedeltaArray, " |
255 |
| - "respectively.", |
256 |
| - DeprecationWarning, |
257 |
| - stacklevel=find_stack_level(), |
258 |
| - ) |
259 |
| - values = new_values |
260 |
| - |
261 | 235 | # We assume maybe_coerce_values has already been called
|
262 | 236 | return type(self)(values, placement=placement, ndim=self.ndim)
|
263 | 237 |
|
@@ -1649,7 +1623,7 @@ class ExtensionBlock(libinternals.Block, EABackedBlock):
|
1649 | 1623 | Notes
|
1650 | 1624 | -----
|
1651 | 1625 | This holds all 3rd-party extension array types. It's also the immediate
|
1652 |
| - parent class for our internal extension types' blocks, CategoricalBlock. |
| 1626 | + parent class for our internal extension types' blocks. |
1653 | 1627 |
|
1654 | 1628 | ExtensionArrays are limited to 1-D.
|
1655 | 1629 | """
|
@@ -2066,17 +2040,6 @@ def convert(
|
2066 | 2040 | return [self.make_block(res_values)]
|
2067 | 2041 |
|
2068 | 2042 |
|
2069 |
| -class CategoricalBlock(ExtensionBlock): |
2070 |
| - # this Block type is kept for backwards-compatibility |
2071 |
| - __slots__ = () |
2072 |
| - |
2073 |
| - # GH#43232, GH#43334 self.values.dtype can be changed inplace until 2.0, |
2074 |
| - # so this cannot be cached |
2075 |
| - @property |
2076 |
| - def dtype(self) -> DtypeObj: |
2077 |
| - return self.values.dtype |
2078 |
| - |
2079 |
| - |
2080 | 2043 | # -----------------------------------------------------------------
|
2081 | 2044 | # Constructor Helpers
|
2082 | 2045 |
|
@@ -2132,8 +2095,6 @@ def get_block_type(dtype: DtypeObj):
|
2132 | 2095 | if isinstance(dtype, SparseDtype):
|
2133 | 2096 | # Need this first(ish) so that Sparse[datetime] is sparse
|
2134 | 2097 | cls = ExtensionBlock
|
2135 |
| - elif isinstance(dtype, CategoricalDtype): |
2136 |
| - cls = CategoricalBlock |
2137 | 2098 | elif vtype is Timestamp:
|
2138 | 2099 | cls = DatetimeTZBlock
|
2139 | 2100 | elif isinstance(dtype, PeriodDtype):
|
@@ -2374,7 +2335,7 @@ def external_values(values: ArrayLike) -> ArrayLike:
|
2374 | 2335 | elif isinstance(values, (DatetimeArray, TimedeltaArray)):
|
2375 | 2336 | # NB: for datetime64tz this is different from np.asarray(values), since
|
2376 | 2337 | # that returns an object-dtype ndarray of Timestamps.
|
2377 |
| - # Avoid FutureWarning in .astype in casting from dt64tz to dt64 |
| 2338 | + # Avoid raising in .astype in casting from dt64tz to dt64 |
2378 | 2339 | return values._data
|
2379 | 2340 | else:
|
2380 | 2341 | return values
|
0 commit comments