Fill NaN values in a pandas dataframe with values of another dataframe

I want to fill nan values in a movie dataframe with values of another dataframe

df_amazon:

 tittle  genre  director
   'a'    'b'     nan

df_disney:

 tittle  genre  director
   'a'    'b'     'c'

The disney and others dataframe has similar movies an uniques movies. I need to find the movie with null value in amazon, search the same movie in another dataframe and replace the values.

Upvotes: 0

Views: 58

Answers (1)

Mahesh Vashishtha
Mahesh Vashishtha

Reputation: 176

I think fillna will work:

import pandas as pd

df_amazon = pd.DataFrame({'title': ['a'], 'genre': ['b'], 'director': [None]})
df_disney = pd.DataFrame({'title': ['a'], 'genre': ['b'], 'director': ['c']})
print(df_amazon.fillna(df_disney))

Upvotes: 1

Related Questions