【发布时间】:2020-09-05 07:59:30
【问题描述】:
我的文件如下所示:
与文本相同的文件:
Uranus Neptune
Date, Time Lng Vel Lng Vel
01.01.2020 0:00:00 32.69520 -0.00884 346.26209 0.01919
01.01.2020 1:00:00 32.69483 -0.00881 346.26289 0.01921
01.01.2020 2:00:00 32.69446 -0.00877 346.26370 0.01923
01.01.2020 3:00:00 32.69410 -0.00874 346.26450 0.01926
01.01.2020 4:00:00 32.69373 -0.00870 346.26530 0.01928
01.01.2020 5:00:00 32.69337 -0.00867 346.26610 0.01930
01.01.2020 6:00:00 32.69301 -0.00863 346.26691 0.01932
我尝试用 pandas 阅读它:
df_ephe = pd.read_csv(file, skiprows = 0, delim_whitespace=True)
但是 Dataframe 看起来不太好。列标题不正确:
Uranus Neptune
Date, Time Lng Vel Lng Vel
01.01.2020 0:00:00 32.69520 -0.00884 346.26209 0.01919
1:00:00 32.69483 -0.00881 346.26289 0.01921
2:00:00 32.69446 -0.00877 346.26370 0.01923
3:00:00 32.69410 -0.00874 346.26450 0.01926
我需要类似的东西:
Date, Time Uranus_Lng Uranus_Vel Neptune_Lng Neptune_Vel
01.01.2020 0:00:00 32.69520 -0.00884 346.26209 0.01919
1:00:00 32.69483 -0.00881 346.26289 0.01921
2:00:00 32.69446 -0.00877 346.26370 0.01923
3:00:00 32.69410 -0.00874 346.26450 0.01926
怎么做?
【问题讨论】: