Skip to content

Commit 5b187f9

Browse files
committed
BUG: Fix series rename called with str altering the name. GH17407
1 parent f797c1d commit 5b187f9

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

pandas/core/dtypes/inference.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,8 @@ def is_list_like(obj):
263263
"""
264264

265265
return (hasattr(obj, '__iter__') and
266-
not isinstance(obj, string_and_binary_types))
266+
not isinstance(obj, string_and_binary_types) and
267+
isinstance(obj, collections.Iterable))
267268

268269

269270
def is_nested_list_like(obj):

pandas/tests/series/test_indexing.py

+10
Original file line numberDiff line numberDiff line change
@@ -2183,6 +2183,16 @@ def test_reindex_fill_value(self):
21832183
expected = Series([False, True, False], index=[1, 2, 3])
21842184
assert_series_equal(result, expected)
21852185

2186+
def test_rename(self):
2187+
2188+
# GH 17407
2189+
s = Series(range(1, 6), index=pd.Index(range(2, 7), name='IntIndex'))
2190+
result = s.rename(str)
2191+
expected = s.rename(lambda i: str(i))
2192+
assert_series_equal(result, expected)
2193+
2194+
assert result.name == expected.name
2195+
21862196
def test_select(self):
21872197
n = len(self.ts)
21882198
result = self.ts.select(lambda x: x >= self.ts.index[n // 2])

0 commit comments

Comments
 (0)