本文整理汇总了Python中pandas.core.base.StringMixin方法的典型用法代码示例。如果您正苦于以下问题:Python base.StringMixin方法的具体用法?Python base.StringMixin怎么用?Python base.StringMixin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pandas.core.base
的用法示例。
在下文中一共展示了base.StringMixin方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_categorical_repr_unicode
# 需要导入模块: from pandas.core import base [as 别名]
# 或者: from pandas.core.base import StringMixin [as 别名]
def test_categorical_repr_unicode(self):
# GH#21002 if len(index) > 60, sys.getdefaultencoding()=='ascii',
# and we are working in PY2, then rendering a Categorical could raise
# UnicodeDecodeError by trying to decode when it shouldn't
class County(StringMixin):
name = u'San Sebastián'
state = u'PR'
def __unicode__(self):
return self.name + u', ' + self.state
cat = pd.Categorical([County() for n in range(61)])
idx = pd.Index(cat)
ser = idx.to_series()
if compat.PY3:
# no reloading of sys, just check that the default (utf8) works
# as expected
repr(ser)
str(ser)
else:
# set sys.defaultencoding to ascii, then change it back after
# the test
with tm.set_defaultencoding('ascii'):
repr(ser)
str(ser)