Append dataframes with different column names - Pandas

后端 未结 3 2068
借酒劲吻你
借酒劲吻你 2020-12-21 16:17

I have 3 dataframes which can be generated from the code shown below

df1= pd.DataFrame({\'person_id\':[1,2,3],\'gender\': [\'Male\',\'Female\',\'Not disclose         


        
3条回答
  •  伪装坚强ぢ
    2020-12-21 17:02

    As mentioned on https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.rename.html , you can pass multiple column names together which can point to same final column name you want. So best approach will be to collect all column names and then map them to common names you need based on some algorithm or manually and then run rename command.

    That algorithm can use both similarity in the names (use TF-IDF) or similarity in values for those columns.

提交回复
热议问题