Skip to content

Commit a255a00

Browse files
Backport PR pandas-dev#51732 on branch 2.0.x (CoW: Add property for references to series class) (pandas-dev#51755)
Backport PR pandas-dev#51732: CoW: Add property for references to series class Co-authored-by: Patrick Hoefler <[email protected]>
1 parent 984390d commit a255a00

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

pandas/core/internals/construction.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -567,10 +567,7 @@ def _homogenize(
567567
# Forces alignment. No need to copy data since we
568568
# are putting it into an ndarray later
569569
val = val.reindex(index, copy=False)
570-
if isinstance(val._mgr, SingleBlockManager):
571-
refs.append(val._mgr._block.refs)
572-
else:
573-
refs.append(None)
570+
refs.append(val._references)
574571
val = val._values
575572
else:
576573
if isinstance(val, dict):

pandas/core/series.py

+7
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
properties,
3535
reshape,
3636
)
37+
from pandas._libs.internals import BlockValuesRefs
3738
from pandas._libs.lib import (
3839
is_range_indexer,
3940
no_default,
@@ -735,6 +736,12 @@ def _values(self):
735736
"""
736737
return self._mgr.internal_values()
737738

739+
@property
740+
def _references(self) -> BlockValuesRefs | None:
741+
if isinstance(self._mgr, SingleArrayManager):
742+
return None
743+
return self._mgr._block.refs
744+
738745
# error: Decorated property not supported
739746
@Appender(base.IndexOpsMixin.array.__doc__) # type: ignore[misc]
740747
@property

0 commit comments

Comments
 (0)