I have the following DataFrame:
Hence the header of the table I imported is divided in two cells I need to shift the cells of the first two columns to shift up. And then to shift the 3 and 4 up. For it to look like this:
I have tried
df.at[1,'x'] = None
But that just deletes de value without shifting any cell.
Get the header with
df.columns = df.loc[0].iloc[:2].tolist() + df.columns[2:].tolist()
df = df.loc[1:].reset_index(drop=True)
A B C D
0 1 2 3 4
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.