Why does Pandas inner join give ValueError: len(left_on) must equal the number of levels in the index of “right”?

后端 未结 2 921
情深已故
情深已故 2021-02-01 00:15

I\'m trying to inner join DataFrame A to DataFrame B and am running into an error.

Here\'s my join statement:

merged = DataFrameA.join(DataFrameB, on=[\'         


        
2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-01 01:06

    Here is another way of performing join. Unlike the answer verified, this is a more general answer applicable to all other types of join.

    Inner Join

    inner join can also be performed by explicitly mentioning it as follows in how:

    pd.merge(df1, df2, on='filename', how='inner')
    

    The same methodology aplies for the other types of join:

    OuterJoin

    pd.merge(df1, df2, on='filename', how='outer')
    

    Left Join

    pd.merge(df1, df2, on='filename', how='left')
    

    Right Join

    pd.merge(df1, df2, on='filename', how='right')
    

提交回复
热议问题