I have the following df:
TAN.SK SHA.LO
A 0.05 0.01
S 0.04 0.44
D 0.08 -0.18
I would like the new df to be as follows:
TAN SHA
A 0.05 0.01
S 0.04 0.44
D 0.08 -0.18
Basically remove from column names .SKand.LO
Here is what I tried:
df.rename(columns=lambda x: x.split('.')[0])
df.columns=df.split('.')[0]
This second case works fine in the case of df.index
source
share