Skip to content

CLN: remove Index._to_embed #22879

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 3 commits into from
Oct 2, 2018
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
14 changes: 1 addition & 13 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,7 @@ def to_series(self, index=None, name=None):
if name is None:
name = self.name

return Series(self._to_embed(), index=index, name=name)
return Series(self.values.copy(), index=index, name=name)

def to_frame(self, index=True, name=None):
"""
Expand Down Expand Up @@ -1177,18 +1177,6 @@ def to_frame(self, index=True, name=None):
result.index = self
return result

def _to_embed(self, keep_tz=False, dtype=None):
"""
*this is an internal non-public method*

return an array repr of this object, potentially casting to object

"""
if dtype is not None:
return self.astype(dtype)._to_embed(keep_tz=keep_tz)

return self.values.copy()

_index_shared_docs['astype'] = """
Create an Index with values cast to dtypes. The class of a new Index
is determined by dtype. When conversion is impossible, a ValueError
Expand Down
18 changes: 4 additions & 14 deletions pandas/core/indexes/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -665,23 +665,13 @@ def to_series(self, keep_tz=False, index=None, name=None):
if name is None:
name = self.name

return Series(self._to_embed(keep_tz), index=index, name=name)

def _to_embed(self, keep_tz=False, dtype=None):
"""
return an array repr of this object, potentially casting to object

This is for internal compat
"""
if dtype is not None:
return self.astype(dtype)._to_embed(keep_tz=keep_tz)

if keep_tz and self.tz is not None:

# preserve the tz & copy
return self.copy(deep=True)
values = self.copy(deep=True)
else:
values = self.values.copy()

return self.values.copy()
return Series(values, index=index, name=name)

def to_period(self, freq=None):
"""
Expand Down
10 changes: 0 additions & 10 deletions pandas/core/indexes/period.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,16 +365,6 @@ def __array_wrap__(self, result, context=None):
# cannot pass _simple_new as it is
return self._shallow_copy(result, freq=self.freq, name=self.name)

def _to_embed(self, keep_tz=False, dtype=None):
"""
return an array repr of this object, potentially casting to object
"""

if dtype is not None:
return self.astype(dtype)._to_embed(keep_tz=keep_tz)

return self.astype(object).values

@property
def size(self):
# Avoid materializing self._values
Expand Down