Reputation: 45
I am learning pandas and python,
I want to fetch more information about movies from IMDB library and save it in an addition column in my already existing data frame.
For example: df['titleId']
has movie IDS in my data frame (total almost 50-60)
(with the help of ImdbPy library), I want to create new column df['movie_name']
in same data frame to store movie names for that particular movie ID df['titleId']
I managed to do it with one value (not in data frame) but not able to handle it in dataframe. Please help.
Code to get movie name is as under:
#### YEAR OF THE MOVE
# importing the module
import imdb
# creating instance of IMDb
ia = imdb.IMDb()
# getting the movie with id
search = ia.get_movie("2082197")
# getting movie year
year = search['year']
# printing movie name and year
print(search['title'] + " : " + str(year))
Upvotes: 0
Views: 380
Reputation: 1006
If I'm understanding you correctly, you are looking for merge
.
As a toy example, if you have a dataframe A with columns (id, name) and another dataframe B with columns (id, year), you can do A.merge(B, how="left")
to get a dataframe C with columns (id, name, year). Note that if B is much smaller than A (i.e., if there are ids in A that are not in B), then you can get nan values in C - you can explore other type of joins for this.
Upvotes: 0