Skip to content

Commit

Permalink
CLN: remove Index._to_embed (pandas-dev#22879)
Browse files Browse the repository at this point in the history
* CLN: remove Index._to_embed

* pep8
  • Loading branch information
jorisvandenbossche authored and TomAugspurger committed Oct 2, 2018
1 parent 6247da0 commit 1d9f76c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 37 deletions.
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

0 comments on commit 1d9f76c

Please sign in to comment.