【发布时间】:2021-02-03 06:06:54
【问题描述】:
我有以下数据框,
AirPressure... WindDirection
Date Location1 Location2.......Location8593 Location8594 Location8595
2010-01-01 xxx. xxx xxx xxx. xxx.
2010-01-02 xxx. xxx xxx xxx. xxx.
2010-01-03 xxx. xxx xxx xxx. xxx.
....
2010-01-01 xxx. xxx xxx xxx. xxx.
...
2020-10-10 xxx. xxx xxx xxx. xxx.
我正在努力使它成为下面的那个。
Date AirPressure-Location1 SoilMoisture-Location1.....WindDirection-Location8595
2010-01-01 xxx. xxx xxx
......
2020-10-10 xxx. xxx xxx
我运行以下命令,
frame.columns = ['-'.join(col).strip() for col in frame.columns.values]
但是我得到了,
Date Location1-AirPressure Location1-SoilMoisture.....Location8595-WindDirection
2010-01-01 xxx. xxx xxx
......
2020-10-10 xxx. xxx xxx
我如何像上面想要的那样翻转名字?
【问题讨论】:
标签: arrays pandas string dataframe