Merge multiple DataFrames Pandas

后端 未结 5 817
無奈伤痛
無奈伤痛 2020-12-14 09:56

This might be considered as a duplicate of a thorough explanation of various approaches, however I can\'t seem to find a solution to my problem there due to a higher number

5条回答
  •  天涯浪人
    2020-12-14 10:31

    I would use append.

    >>> df1.append(df2).append(df3).sort_values('depth')
    
            VAR1     VAR2    VAR3  depth    profile
    0  38.196202      NaN     NaN    0.5  profile_1
    1  38.198002      NaN     NaN    0.6  profile_1
    0        NaN  0.20440     NaN    0.6  profile_1
    1        NaN  0.20442     NaN    1.1  profile_1
    2        NaN  0.20446     NaN    1.2  profile_1
    0        NaN      NaN  15.188    1.2  profile_1
    2  38.200001      NaN     NaN    1.3  profile_1
    1        NaN      NaN  15.182    1.3  profile_1
    2        NaN      NaN  15.182    1.4  profile_1
    

    Obviously if you have a lot of dataframes, just make a list and loop through them.

提交回复
热议问题