Skip to content

Commit f0ab1c5

Browse files
authored
REF: rename _data->_mgr (#33054)
1 parent 1e5afdc commit f0ab1c5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+200
-189
lines changed

pandas/_libs/properties.pyx

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ cdef class AxisProperty:
5656
list axes
5757

5858
if obj is None:
59-
# Only instances have _data, not classes
59+
# Only instances have _mgr, not classes
6060
return self
6161
else:
62-
axes = obj._data.axes
62+
axes = obj._mgr.axes
6363
return axes[self.axis]
6464

6565
def __set__(self, obj, value):

pandas/_libs/reduction.pyx

+4-4
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ cdef class Reducer:
127127
name = labels[i]
128128

129129
object.__setattr__(
130-
cached_typ._data._block, 'values', chunk)
130+
cached_typ._mgr._block, 'values', chunk)
131131
object.__setattr__(cached_typ, 'name', name)
132132
res = self.f(cached_typ)
133133
else:
@@ -180,8 +180,8 @@ cdef class _BaseGrouper:
180180
# to a 1-d ndarray like datetime / timedelta / period.
181181
object.__setattr__(cached_ityp, '_index_data', islider.buf)
182182
cached_ityp._engine.clear_mapping()
183-
object.__setattr__(cached_typ._data._block, 'values', vslider.buf)
184-
object.__setattr__(cached_typ._data._block, 'mgr_locs',
183+
object.__setattr__(cached_typ._mgr._block, 'values', vslider.buf)
184+
object.__setattr__(cached_typ._mgr._block, 'mgr_locs',
185185
slice(len(vslider.buf)))
186186
object.__setattr__(cached_typ, '_index', cached_ityp)
187187
object.__setattr__(cached_typ, 'name', self.name)
@@ -551,7 +551,7 @@ cdef class BlockSlider:
551551
self.dummy = frame[:0]
552552
self.index = self.dummy.index
553553

554-
self.blocks = [b.values for b in self.dummy._data.blocks]
554+
self.blocks = [b.values for b in self.dummy._mgr.blocks]
555555

556556
for x in self.blocks:
557557
util.set_array_not_contiguous(x)

pandas/_libs/src/ujson/python/objToJSON.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ static PyObject *get_sub_attr(PyObject *obj, char *attr, char *subAttr) {
279279
}
280280

281281
static int is_simple_frame(PyObject *obj) {
282-
PyObject *check = get_sub_attr(obj, "_data", "is_mixed_type");
282+
PyObject *check = get_sub_attr(obj, "_mgr", "is_mixed_type");
283283
int ret = (check == Py_False);
284284

285285
if (!check) {
@@ -760,7 +760,7 @@ void PdBlock_iterBegin(JSOBJ _obj, JSONTypeContext *tc) {
760760
goto BLKRET;
761761
}
762762

763-
blocks = get_sub_attr(obj, "_data", "blocks");
763+
blocks = get_sub_attr(obj, "_mgr", "blocks");
764764
if (!blocks) {
765765
GET_TC(tc)->iterNext = NpyArr_iterNextNone;
766766
goto BLKRET;

pandas/core/algorithms.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1645,7 +1645,7 @@ def take_nd(
16451645
if arr.flags.f_contiguous and axis == arr.ndim - 1:
16461646
# minor tweak that can make an order-of-magnitude difference
16471647
# for dataframes initialized directly from 2-d ndarrays
1648-
# (s.t. df.values is c-contiguous and df._data.blocks[0] is its
1648+
# (s.t. df.values is c-contiguous and df._mgr.blocks[0] is its
16491649
# f-contiguous transpose)
16501650
out = np.empty(out_shape, dtype=dtype, order="F")
16511651
else:

pandas/core/apply.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def get_result(self):
165165
# ufunc
166166
elif isinstance(self.f, np.ufunc):
167167
with np.errstate(all="ignore"):
168-
results = self.obj._data.apply("apply", func=self.f)
168+
results = self.obj._mgr.apply("apply", func=self.f)
169169
return self.obj._constructor(
170170
data=results, index=self.index, columns=self.columns, copy=False
171171
)

pandas/core/frame.py

+16-16
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ def __init__(
431431
dtype = self._validate_dtype(dtype)
432432

433433
if isinstance(data, DataFrame):
434-
data = data._data
434+
data = data._mgr
435435

436436
if isinstance(data, BlockManager):
437437
mgr = self._init_mgr(
@@ -590,10 +590,10 @@ def _is_homogeneous_type(self) -> bool:
590590
... "B": np.array([1, 2], dtype=np.int64)})._is_homogeneous_type
591591
False
592592
"""
593-
if self._data.any_extension_types:
594-
return len({block.dtype for block in self._data.blocks}) == 1
593+
if self._mgr.any_extension_types:
594+
return len({block.dtype for block in self._mgr.blocks}) == 1
595595
else:
596-
return not self._data.is_mixed_type
596+
return not self._mgr.is_mixed_type
597597

598598
# ----------------------------------------------------------------------
599599
# Rendering Methods
@@ -2537,7 +2537,7 @@ def _ixs(self, i: int, axis: int = 0):
25372537
"""
25382538
# irow
25392539
if axis == 0:
2540-
new_values = self._data.fast_xs(i)
2540+
new_values = self._mgr.fast_xs(i)
25412541

25422542
# if we are a copy, mark as such
25432543
copy = isinstance(new_values, np.ndarray) and new_values.base is None
@@ -2554,7 +2554,7 @@ def _ixs(self, i: int, axis: int = 0):
25542554
else:
25552555
label = self.columns[i]
25562556

2557-
values = self._data.iget(i)
2557+
values = self._mgr.iget(i)
25582558
result = self._box_col_values(values, label)
25592559

25602560
# this is a cached value, mark it so
@@ -2865,7 +2865,7 @@ def _ensure_valid_index(self, value):
28652865
"and a value that cannot be converted to a Series"
28662866
) from err
28672867

2868-
self._data = self._data.reindex_axis(
2868+
self._mgr = self._mgr.reindex_axis(
28692869
value.index.copy(), axis=1, fill_value=np.nan
28702870
)
28712871

@@ -3313,7 +3313,7 @@ def insert(self, loc, column, value, allow_duplicates=False) -> None:
33133313
"""
33143314
self._ensure_valid_index(value)
33153315
value = self._sanitize_column(column, value, broadcast=False)
3316-
self._data.insert(loc, column, value, allow_duplicates=allow_duplicates)
3316+
self._mgr.insert(loc, column, value, allow_duplicates=allow_duplicates)
33173317

33183318
def assign(self, **kwargs) -> "DataFrame":
33193319
r"""
@@ -3494,7 +3494,7 @@ def reindexer(value):
34943494
@property
34953495
def _series(self):
34963496
return {
3497-
item: Series(self._data.iget(idx), index=self.index, name=item)
3497+
item: Series(self._mgr.iget(idx), index=self.index, name=item)
34983498
for idx, item in enumerate(self.columns)
34993499
}
35003500

@@ -4403,7 +4403,7 @@ def _maybe_casted_values(index, labels=None):
44034403
values_dtype = values.dtype
44044404

44054405
if issubclass(values_type, DatetimeLikeArray):
4406-
values = values._data
4406+
values = values._data # TODO: can we de-kludge yet?
44074407

44084408
if mask.any():
44094409
values, _ = maybe_upcast_putmask(values, mask, np.nan)
@@ -4787,7 +4787,7 @@ def sort_values(
47874787
k, kind=kind, ascending=ascending, na_position=na_position
47884788
)
47894789

4790-
new_data = self._data.take(
4790+
new_data = self._mgr.take(
47914791
indexer, axis=self._get_block_manager_axis(axis), verify=False
47924792
)
47934793

@@ -4922,7 +4922,7 @@ def sort_index(
49224922
)
49234923

49244924
baxis = self._get_block_manager_axis(axis)
4925-
new_data = self._data.take(indexer, axis=baxis, verify=False)
4925+
new_data = self._mgr.take(indexer, axis=baxis, verify=False)
49264926

49274927
# reconstruct axis if needed
49284928
new_data.axes[baxis] = new_data.axes[baxis]._sort_levels_monotonic()
@@ -6661,7 +6661,7 @@ def diff(self, periods: int = 1, axis: Axis = 0) -> "DataFrame":
66616661
5 NaN NaN NaN
66626662
"""
66636663
bm_axis = self._get_block_manager_axis(axis)
6664-
new_data = self._data.diff(n=periods, axis=bm_axis)
6664+
new_data = self._mgr.diff(n=periods, axis=bm_axis)
66656665
return self._constructor(new_data)
66666666

66676667
# ----------------------------------------------------------------------
@@ -7855,7 +7855,7 @@ def count(self, axis=0, level=None, numeric_only=False):
78557855
if len(frame._get_axis(axis)) == 0:
78567856
result = Series(0, index=frame._get_agg_axis(axis))
78577857
else:
7858-
if frame._is_mixed_type or frame._data.any_extension_types:
7858+
if frame._is_mixed_type or frame._mgr.any_extension_types:
78597859
# the or any_extension_types is really only hit for single-
78607860
# column frames with an extension array
78617861
result = notna(frame).sum(axis=axis)
@@ -7979,7 +7979,7 @@ def blk_func(values):
79797979

79807980
# After possibly _get_data and transposing, we are now in the
79817981
# simple case where we can use BlockManager._reduce
7982-
res = df._data.reduce(blk_func)
7982+
res = df._mgr.reduce(blk_func)
79837983
assert isinstance(res, dict)
79847984
if len(res):
79857985
assert len(res) == max(list(res.keys())) + 1, res.keys()
@@ -8421,7 +8421,7 @@ def quantile(self, q=0.5, axis=0, numeric_only=True, interpolation="linear"):
84218421
return self._constructor([], index=q, columns=cols)
84228422
return self._constructor_sliced([], index=cols, name=q, dtype=np.float64)
84238423

8424-
result = data._data.quantile(
8424+
result = data._mgr.quantile(
84258425
qs=q, axis=1, interpolation=interpolation, transposed=is_transposed
84268426
)
84278427

0 commit comments

Comments
 (0)