合并两行并为Pandas DataFrame形成列标题

时间:2019-06-11 10:05:30

标签: python pandas dataframe

我有一个熊猫数据框,如下所示:

    0      1             2    3    4    5    6    7    8    9    ...    
0      USAF   WBAN  YR--MODAHRMN  DIR  SPD  GUS  CLG  SKC    L    M   ...     
1       NaN    NaN           GMT  NaN  MPH  MPH  NaN  NaN  NaN  NaN   ...     
2    444540  99999  201801010000  ***    0  ***  722  SCT    *    *   ...     
3    444540  99999  201801010050  ***    0  ***   30  ***    *    *   ...     
4    444540  99999  201801010150  990    2  ***  100  ***    *    *   ...     
5    444540  99999  201801010250  ***    0  ***  100  ***    *    *   ...

我想合并前两行,删除NaN值,并使其成为列标题,如下所示:

      USAF   WBAN  YR--MODAHRMN  DIR   SPD  GUS  CLG  SKC    L    M   ...     
                            GMT        MPH  MPH                      ...     
0    444540  99999  201801010000  ***   0  ***  722  SCT    *    *   ...     
1    444540  99999  201801010050  ***   0  ***   30  ***    *    *   ...     

有没有办法我可以正确地做到这一点?

0 个答案:

没有答案