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

Creating series with multiindex from dict with tuple keys with None #18505

Closed
fumitoh opened this Issue Nov 26, 2017 · 2 comments

Comments

Projects
None yet
3 participants
@fumitoh
Contributor

fumitoh commented Nov 26, 2017

Code Sample

import pandas as pd

data1={(1, 2): 3,
       (4, None): 6}

s1 = pd.Series(data=data1)

data2={(1, 2): 3,
       (None, 5): 6}

s2 = pd.Series(data=data2)

Problem description

s1 has MultiIndex while s2 has Index of tuple just because the second element of the data2 has None as the first element of the key tuple.

>>> s1
1  2      3.0
4  NaN    NaN
dtype: float64
>>> s2
(1, 2)       3
(None, 5)    6
dtype: int64

Is this a bug? or is this how it's supposed to be?

FYI, both of mi1 and mi2 below yield MultiIndex as I expect.

mi1 = pd.MultiIndex.from_tuples([(1, 2), (4, None)])
mi2 = pd.MultiIndex.from_tuples([(1, 2), (None, 5)])
@toobaz

This comment has been minimized.

Member

toobaz commented Nov 27, 2017

This comes from

In [3]: pd.Index(list(data2))
Out[3]: Index([(1, 2), (None, 5)], dtype='object')

(so won't be fixed by #18496 ).

@toobaz

This comment has been minimized.

Member

toobaz commented Nov 27, 2017

Related to #18484

toobaz added a commit to toobaz/pandas that referenced this issue Nov 27, 2017

toobaz added a commit to toobaz/pandas that referenced this issue Nov 27, 2017

toobaz added a commit to toobaz/pandas that referenced this issue Nov 27, 2017

@jreback jreback added this to the 0.22.0 milestone Nov 27, 2017

toobaz added a commit to toobaz/pandas that referenced this issue Nov 27, 2017

toobaz added a commit to toobaz/pandas that referenced this issue Nov 27, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment