pandas return columns in dataframe that are not in other dataframe

后端 未结 4 1664
暖寄归人
暖寄归人 2020-12-20 03:22

I have two dataframes that look like this:

df_1 = pd.DataFrame({
\'A\' : [1.0, 2.0, 3.0, 4.0],
\'B\' : [100, 200, 300, 400],
\'C\' : [2, 3, 4, 5] 
                   


        
4条回答
  •  臣服心动
    2020-12-20 03:44

    You can use:

    set(df_2.columns.values) - set(df_1.columns.values)
    

    which returns a set containing column labels of columns in df_2 but not in df_1.

提交回复
热议问题