Skip to content

FIX disallow MultiIndex in Series constructor GH4187 #4190

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 13, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ pandas 0.12
- Fixed an esoteric excel reading bug, xlrd>= 0.9.0 now required for excel
support. Should provide python3 support (for reading) which has been
lacking. (:issue:`3164`)
- Disallow Series constructor called with MultiIndex which caused segfault (:issue:`4187`)
- Allow unioning of date ranges sharing a timezone (:issue:`3491`)
- Fix to_csv issue when having a large number of rows and ``NaT`` in some
columns (:issue:`3437`)
Expand Down
3 changes: 3 additions & 0 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,9 @@ def __new__(cls, data=None, index=None, dtype=None, name=None,
if data is None:
data = {}

if isinstance(data, MultiIndex):
raise NotImplementedError

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

Expand Down
4 changes: 4 additions & 0 deletions pandas/tests/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,10 @@ def test_constructor(self):
xp = 'Series'
self.assertEqual(rs, xp)

# raise on MultiIndex GH4187
m = MultiIndex.from_arrays([[1, 2], [3,4]])
self.assertRaises(NotImplementedError, Series, m)

def test_constructor_empty(self):
empty = Series()
empty2 = Series([])
Expand Down