Skip to content

Commit e7d7def

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 5fdc114 commit e7d7def

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

Diff for: pandas/core/generic.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1906,8 +1906,7 @@ def _slice(self, slobj, axis=0, kind=None):
19061906
return result
19071907

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

0 commit comments

Comments
 (0)