• Register
1 vote
604 views

Problem :

Currently I am learning Pandas. I want to do inner join DataFrame1 to DataFrame2. But I am facing below error.

“Len(left_on) must equal the number of levels in the index of "right"”

Please find below my join statement for your reference.

merged = DataFrame1.join(DataFrame2, on=['Code','Date'])

Please let me know why am I facing above error?

8 5 2
3,230 points

1 Answer

1 vote

Solution :

I can help you in fixing your error related to Pandas.

Please find below another way of performing join.

Inner Join

The Inner Join can also be performed by the use by explicitly mentioning it as shown below for your reference in how:

pd.merge(DataFrame1, DataFrame2, on='filename', how='inner')

OuterJoin

The Outer Join can also be performed by the use by explicitly mentioning it as shown below for your reference in how:

pd.merge(DataFrame1, DataFrame2, on='filename', how='outer')

 Left Join

The Left Join can also be performed by the use by explicitly mentioning it as shown below for your reference in how:

pd.merge(DataFrame1, DataFrame2, on='filename', how='left’)

Right Join

The Right Join can also be performed by the use by explicitly mentioning it as shown below for your reference in how:

pd.merge(DataFrame1, DataFrame2, on='filename', how='right’)

 Above answer is the generalized answer for all the join types.

I hope it will help you in fixing your issue.

8 4
5,680 points

Related questions

0 votes
1 answer 2.3K views
2.3K views
Problem : I have a big dataframe and I am trying to split that and after concat that but facing following error first argument must be an iterable of pandas objects, you passed an object of type "dataframe"
asked Nov 14, 2019 peterlaw 6.9k points
1 vote
2 answers 194 views
194 views
Anyone aware of this error. I am facing this issue in this function. It is not going to IF statement where I put my filter condition which is true then simply raise Error and without IF it is working but I want to put the filter condition which checks date between ... "value"]) It is not going to IF statement where I put my filter condition which is true then simply raise Error. Any suggestion?
asked May 8 Kashish
1 vote
2 answers 677 views
677 views
Problem : I am receiveing error as the truth value of a dataframe is ambiguous. use a.empty, a.bool(), a.item(), a.any() or a.all().
asked Nov 11, 2019 peterlaw 6.9k points
1 vote
1 answer 831 views
831 views
Problem : I am very new to R programming. Currently I am learning R programming. I have below two tables I have asembled them via cbind(). My first Table table_alpha is as below: x1 col1_x1 col2_x1 A "1999 12 01 00:00" " 0.4" " 0" B "1999 12 02 00:00" " - ... = table_num[,1], fill=-9999) Please find below the error: “Error in fix.by(by.x, x) : 'by' must specify uniquely valid columns”.
asked Mar 28 morrisBson 3.2k points
0 votes
1 answer 431 views
431 views
Problem : I am trying to merge data in R but facing following error error in fix.by(by.x, x) : 'by' must specify one or more columns as numbers, names or logical
asked Nov 15, 2019 peterlaw 6.9k points