Merge columns in pandas

Question:

I would like to merge two dataframes with pandas by keeping the lines for which the title of the content on Netflix and its year are identical to the main title and the year of release of my second imdb datafram.

Do you know how I can do this?

I tried that, but unfortunately I don’t sort my dataframes well according to the columns

As you can see, the columns in my two dataframes do not have the same names

netflix.merge(imdb, how='left', left_index=True, right_index=True)

enter image description here

enter image description here

Asked By: user15445043

||

Answers:

Your syntax looks to me incorrect , you did not pass two dataframe argument , refer the example below, it should help

import pandas as pd
left = pd.DataFrame({
   'id':[1,2,3,4,5],
   'Name': ['Alex', 'Amy', 'Allen', 'Alice', 'Ayoung'],
   'subject_id':['sub1','sub2','sub4','sub6','sub5']})
right = pd.DataFrame({
   'id':[1,2,3,4,5],
   'Name': ['Billy', 'Brian', 'Bran', 'Bryce', 'Betty'],
   'subject_id':['sub2','sub4','sub3','sub6','sub5']})
print(pd.merge(left, right, left_index=True, right_index=True))
Answered By: Vikram Karthic

I would like to have the netflix and imdb data. Is it possible to send them to my address ([email protected])? What did you put in the merge function to make it work?

Answered By: Amine Chakli