Skip to content

Commit e02244d

Browse files
committed
BUG: fixes 'string_types' encoding failure with unicode cols in py2
As part of warning check, object type of potential attributes was checked for subtypes of pd.compat.str_types before being checked for overlap with methods defined on ndframes. This causes decode errors in Python2 when users attempt to add columns with unicode column names. Fix is to compare against `str`.
1 parent e5cc166 commit e02244d

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

pandas/core/generic.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1907,8 +1907,7 @@ def _slice(self, slobj, axis=0, kind=None):
19071907
return result
19081908

19091909
def _set_item(self, key, value):
1910-
if (isinstance(key, string_types)
1911-
and callable(getattr(self, key, None))):
1910+
if isinstance(key, str) and callable(getattr(self, key, None)):
19121911
warnings.warn("Column name '{key}' collides with a built-in "
19131912
"method, which will cause unexpected attribute "
19141913
"behavior".format(key=key), stacklevel=3)

0 commit comments

Comments
 (0)