Skip to content

Commit 8a6f75e

Browse files
committed
Fix tests for series
1 parent 5122a43 commit 8a6f75e

File tree

4 files changed

+312
-571
lines changed

4 files changed

+312
-571
lines changed

pandas/core/generic.py

+1
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,7 @@ def set_index(self, keys, drop=True, append=False, inplace=False,
773773
names.append(None)
774774
# from here on, col must be a column label
775775
else:
776+
print(col, obj)
776777
level = obj[col]._values
777778
names.append(col)
778779
if drop:

pandas/core/series.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -1121,15 +1121,19 @@ def set_index(self, arrays, append=False, inplace=False,
11211121
>>> ...
11221122
"""
11231123

1124-
if (not isinstance(keys, (Series, Index, MultiIndex, list, np.ndarray))
1125-
or (isinstance(keys, list)
1124+
if (not isinstance(arrays,
1125+
(Series, Index, MultiIndex, list, np.ndarray))
1126+
or (isinstance(arrays, list)
11261127
and any(not isinstance(x, (Series, Index, MultiIndex,
11271128
list, np.ndarray))
1128-
for x in keys))):
1129+
for x in arrays))):
11291130
raise ValueError('arrays must be Series, Index, MultiIndex, '
11301131
'np.ndarray or list containing containing only'
11311132
'Series, Index, MultiIndex, list, np.ndarray')
11321133

1134+
if not isinstance(arrays, list):
1135+
arrays = [arrays]
1136+
11331137
return super(Series, self).set_index(keys=arrays, drop=False,
11341138
append=append, inplace=inplace,
11351139
verify_integrity=verify_integrity)

0 commit comments

Comments
 (0)