• Register
1 vote
1.2k 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

Please log in or register to answer this question.

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 85 views
85 views
Problem: valueerror: must have equal len keys and value when setting with an iterable
asked Feb 9 charles mathews 3.8k points
1 vote
1 answer 1.7K views
1.7K 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, 2020 morrisBson 3.2k points
0 votes
1 answer 886 views
886 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
0 votes
1 answer 3.2K views
3.2K 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
0 votes
1 answer 41 views
41 views
Problem: I am trying to deploy multi-index with pandas and I keep getting: ValueError: Index contains duplicate entries, cannot reshape Given a dataset with four columns: id (string) date (string) location (string) meaning (float) I first set up a 3- ... Index contains duplicate entries, ' 146 'cannot reshape') 147 ValueError: Index contains duplicate entries, cannot reshape What's going on here?
asked Dec 25, 2020 sasha 13.2k points
0 votes
1 answer 245 views
245 views
Problem : I am new to matlab and nntool. Currently I want to implement the neural network with the use of matlab using nntool. I am facing below error message. I am unable to understand the error message. **??? Insufficient number of outputs from right hand ... : Insufficient number of outputs from right hand side of equal sign to satisfy assignment.** How can I fix the above error message?
asked Feb 19, 2020 mphil 2.3k points
0 votes
1 answer 307 views
307 views
Iterates over a big list of .mp3 links to get the metadata tags and save it to an Excel file. Results in this error. I appreciate any help. Thanks. #print is_connected(); # Create a Pandas dataframe from the data. df = pd.DataFrame({'Links' : lines , ... \pandas\core\frame.py", line 5457, in extract_index raise ValueError('arrays must all be same length') ValueError: arrays must all be same length
asked Oct 25, 2020 psandprop 2.4k points
1 vote
2 answers 520 views
520 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, 2020 Kashish
1 vote
2 answers 1.4K views
1.4K 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