Skip to content

CoW: Add property for references to series class #51732

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 1 commit into from
Mar 3, 2023
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
5 changes: 1 addition & 4 deletions pandas/core/internals/construction.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,10 +567,7 @@ def _homogenize(
# Forces alignment. No need to copy data since we
# are putting it into an ndarray later
val = val.reindex(index, copy=False)
if isinstance(val._mgr, SingleBlockManager):
refs.append(val._mgr._block.refs)
else:
refs.append(None)
refs.append(val._references)
val = val._values
else:
if isinstance(val, dict):
Expand Down
7 changes: 7 additions & 0 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
properties,
reshape,
)
from pandas._libs.internals import BlockValuesRefs
from pandas._libs.lib import (
is_range_indexer,
no_default,
Expand Down Expand Up @@ -734,6 +735,12 @@ def _values(self):
"""
return self._mgr.internal_values()

@property
def _references(self) -> BlockValuesRefs | None:
if isinstance(self._mgr, SingleArrayManager):
return None
return self._mgr._block.refs

# error: Decorated property not supported
@Appender(base.IndexOpsMixin.array.__doc__) # type: ignore[misc]
@property
Expand Down