Skip to content

Commit 267e003

Browse files
jbrockmendelrhshadrach
authored andcommitted
REF: avoid passing SingleBlockManager to Series (pandas-dev#33727)
1 parent 7b62393 commit 267e003

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

pandas/core/frame.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -3649,7 +3649,9 @@ def reindexer(value):
36493649
@property
36503650
def _series(self):
36513651
return {
3652-
item: Series(self._mgr.iget(idx), index=self.index, name=item)
3652+
item: Series(
3653+
self._mgr.iget(idx), index=self.index, name=item, fastpath=True
3654+
)
36533655
for idx, item in enumerate(self.columns)
36543656
}
36553657

pandas/core/generic.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -11208,9 +11208,7 @@ def block_accum_func(blk_values):
1120811208

1120911209
result = self._mgr.apply(block_accum_func)
1121011210

11211-
d = self._construct_axes_dict()
11212-
d["copy"] = False
11213-
return self._constructor(result, **d).__finalize__(self, method=name)
11211+
return self._constructor(result).__finalize__(self, method=name)
1121411212

1121511213
return set_function_name(cum_func, name, cls)
1121611214

pandas/core/series.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -259,12 +259,8 @@ def __init__(
259259
# astype copies
260260
data = data.astype(dtype)
261261
else:
262-
# need to copy to avoid aliasing issues
262+
# GH#24096 we need to ensure the index remains immutable
263263
data = data._values.copy()
264-
if isinstance(data, ABCDatetimeIndex) and data.tz is not None:
265-
# GH#24096 need copy to be deep for datetime64tz case
266-
# TODO: See if we can avoid these copies
267-
data = data._values.copy(deep=True)
268264
copy = False
269265

270266
elif isinstance(data, np.ndarray):
@@ -280,6 +276,7 @@ def __init__(
280276
index = data.index
281277
else:
282278
data = data.reindex(index, copy=copy)
279+
copy = False
283280
data = data._mgr
284281
elif is_dict_like(data):
285282
data, index = self._init_dict(data, index, dtype)

0 commit comments

Comments
 (0)