Skip to content

Commit

Permalink
BUG: unhandled case in Series with index=list of arrays #831
Browse files Browse the repository at this point in the history
  • Loading branch information
Chang She committed May 7, 2012
1 parent 6189392 commit bc02347
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 3 additions & 5 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,14 +272,15 @@ def __new__(cls, data=None, index=None, dtype=None, name=None,
if data is None:
data = {}

if index is not None:
index = _ensure_index(index)

if isinstance(data, Series):
if index is None:
index = data.index
elif isinstance(data, dict):
if index is None:
index = Index(sorted(data))
else:
index = _ensure_index(index)
try:
if isinstance(index, DatetimeIndex):
# coerce back to datetime objects for lookup
Expand All @@ -293,9 +294,6 @@ def __new__(cls, data=None, index=None, dtype=None, name=None,
if dtype is not None:
dtype = np.dtype(dtype)

if index is not None:
index = _ensure_index(index)

subarr = _sanitize_array(data, index, dtype, copy,
raise_cast_failure=True)

Expand Down
4 changes: 4 additions & 0 deletions pandas/tests/test_multilevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ def test_series_constructor(self):
['x', 'y', 'x', 'y']])
self.assert_(isinstance(multi.index, MultiIndex))

multi = Series(range(4), index=[['a', 'a', 'b', 'b'],
['x', 'y', 'x', 'y']])
self.assert_(isinstance(multi.index, MultiIndex))

def test_reindex_level(self):
# axis=0
month_sums = self.ymd.sum(level='month')
Expand Down

0 comments on commit bc02347

Please sign in to comment.