Closed
Description
Right now we have:
>>> pd.DataFrame({(1,2):pd.Series([2.3])}).columns
MultiIndex(levels=[[1], [2]],
labels=[[0], [0]])
>>> pd.Index([(1,2)])
MultiIndex(levels=[[1], [2]],
labels=[[0], [0]])
Could we have an option to suppress this behavior? One problem this causes is that the .rename
method is not uniform and does not work if a tuple is silently converted:
>>> pd.DataFrame({(1,2):pd.Series([2.3])}).rename(columns={(1,2):(1,3)})
1
2
0 2.3
To see why such behavior is problematic consider the following unintuitive example:
>>> a = ('a', 1)
>>> b = ('b', 2)
>>> pd.DataFrame({a:pd.Series([2,3])})
a
1
0 2
1 3
>>> pd.DataFrame({a:pd.Series([2,3])}).rename(columns={a:b})
a
1
0 2
1 3