import pandas as pd
df = pd.DataFrame([[0,0], [0,0]], index=['a', 'b'])
df.columns = [(1,2), (3,4)]
df.at['a', (1,2)] = 100
print(df)
My column name is a tuple and I want to set value 100 to one of rhe cell. The expected result is
(1, 2) (3, 4)
a 100 0
b 0 0
But I got
(1, 2) (3, 4) 1 2
a 0 0 100.0 100.0
b 0 0 NaN NaN
Namely, pandas regards the tuple as two new columns. I also tried .loc
and got the same result.
Actually it seems depend on the IDE, since in Jupternote, it is the first one. But in pycharm, it become the unexpected one.