Skip to content

Commit 241af3d

Browse files
topper-123jreback
authored andcommitted
CLN: remove __unicode__ from pandas.core.dtypes (#26415)
1 parent c891431 commit 241af3d

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

pandas/core/dtypes/dtypes.py

+7-10
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,11 @@ class PandasExtensionDtype(ExtensionDtype):
126126
isnative = 0
127127
_cache = {} # type: Dict[str_type, 'PandasExtensionDtype']
128128

129-
def __unicode__(self):
130-
return self.name
131-
132129
def __str__(self):
133130
"""
134131
Return a string representation for a particular Object
135132
"""
136-
return self.__unicode__()
133+
return self.name
137134

138135
def __bytes__(self):
139136
"""
@@ -142,7 +139,7 @@ def __bytes__(self):
142139
from pandas._config import get_option
143140

144141
encoding = get_option("display.encoding")
145-
return self.__unicode__().encode(encoding, 'replace')
142+
return str(self).encode(encoding, 'replace')
146143

147144
def __repr__(self):
148145
"""
@@ -707,7 +704,7 @@ def construct_from_string(cls, string):
707704

708705
raise TypeError("Could not construct DatetimeTZDtype")
709706

710-
def __unicode__(self):
707+
def __str__(self):
711708
return "datetime64[{unit}, {tz}]".format(unit=self.unit, tz=self.tz)
712709

713710
@property
@@ -837,12 +834,12 @@ def construct_from_string(cls, string):
837834
pass
838835
raise TypeError("could not construct PeriodDtype")
839836

840-
def __unicode__(self):
841-
return str(self.name)
837+
def __str__(self):
838+
return self.name
842839

843840
@property
844841
def name(self):
845-
return str("period[{freq}]".format(freq=self.freq.freqstr))
842+
return "period[{freq}]".format(freq=self.freq.freqstr)
846843

847844
@property
848845
def na_value(self):
@@ -1007,7 +1004,7 @@ def construct_from_string(cls, string):
10071004
def type(self):
10081005
return Interval
10091006

1010-
def __unicode__(self):
1007+
def __str__(self):
10111008
if self.subtype is None:
10121009
return "interval"
10131010
return "interval[{subtype}]".format(subtype=self.subtype)

0 commit comments

Comments
 (0)