Skip to content

Commit 1d9f76c

Browse files
jorisvandenbosscheTomAugspurger
authored andcommitted
CLN: remove Index._to_embed (pandas-dev#22879)
* CLN: remove Index._to_embed * pep8
1 parent 6247da0 commit 1d9f76c

File tree

3 files changed

+5
-37
lines changed

3 files changed

+5
-37
lines changed

pandas/core/indexes/base.py

+1-13
Original file line numberDiff line numberDiff line change
@@ -1114,7 +1114,7 @@ def to_series(self, index=None, name=None):
11141114
if name is None:
11151115
name = self.name
11161116

1117-
return Series(self._to_embed(), index=index, name=name)
1117+
return Series(self.values.copy(), index=index, name=name)
11181118

11191119
def to_frame(self, index=True, name=None):
11201120
"""
@@ -1177,18 +1177,6 @@ def to_frame(self, index=True, name=None):
11771177
result.index = self
11781178
return result
11791179

1180-
def _to_embed(self, keep_tz=False, dtype=None):
1181-
"""
1182-
*this is an internal non-public method*
1183-
1184-
return an array repr of this object, potentially casting to object
1185-
1186-
"""
1187-
if dtype is not None:
1188-
return self.astype(dtype)._to_embed(keep_tz=keep_tz)
1189-
1190-
return self.values.copy()
1191-
11921180
_index_shared_docs['astype'] = """
11931181
Create an Index with values cast to dtypes. The class of a new Index
11941182
is determined by dtype. When conversion is impossible, a ValueError

pandas/core/indexes/datetimes.py

+4-14
Original file line numberDiff line numberDiff line change
@@ -665,23 +665,13 @@ def to_series(self, keep_tz=False, index=None, name=None):
665665
if name is None:
666666
name = self.name
667667

668-
return Series(self._to_embed(keep_tz), index=index, name=name)
669-
670-
def _to_embed(self, keep_tz=False, dtype=None):
671-
"""
672-
return an array repr of this object, potentially casting to object
673-
674-
This is for internal compat
675-
"""
676-
if dtype is not None:
677-
return self.astype(dtype)._to_embed(keep_tz=keep_tz)
678-
679668
if keep_tz and self.tz is not None:
680-
681669
# preserve the tz & copy
682-
return self.copy(deep=True)
670+
values = self.copy(deep=True)
671+
else:
672+
values = self.values.copy()
683673

684-
return self.values.copy()
674+
return Series(values, index=index, name=name)
685675

686676
def to_period(self, freq=None):
687677
"""

pandas/core/indexes/period.py

-10
Original file line numberDiff line numberDiff line change
@@ -365,16 +365,6 @@ def __array_wrap__(self, result, context=None):
365365
# cannot pass _simple_new as it is
366366
return self._shallow_copy(result, freq=self.freq, name=self.name)
367367

368-
def _to_embed(self, keep_tz=False, dtype=None):
369-
"""
370-
return an array repr of this object, potentially casting to object
371-
"""
372-
373-
if dtype is not None:
374-
return self.astype(dtype)._to_embed(keep_tz=keep_tz)
375-
376-
return self.astype(object).values
377-
378368
@property
379369
def size(self):
380370
# Avoid materializing self._values

0 commit comments

Comments
 (0)