So I have one csv with 'films' in a database that have a unique ID

movie_title      | ID       | popularity
spider-man        unique ID   4.2
captain marvel    unique ID   9.9

Then about every week, I would like to update that popularity with a new one from another list of movies.

New movie list:

movie_title      | ID       | popularity
spider-man        unique ID   5.5
captain marvel    unique ID   7.4

How can I merge these two csv and output a new csv with only the value popularity updating? I have other values that also change over the week, but I just did popularity for simplicity. The unique ID must be in the new csv as well not only the changes; because, when I resubmit back to the database that is the only way that it will update with the ID.

The second list does not contain the ID's.


1 Answer 1


What you need is a pandas.DataFrame.update.

Use pandas.read_csv to read the csv file to a Pandas DataFrame, then do the update. Once you have made the update you can use pandas.DataFrame.to_csv to convert it back to a csv.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.