I have a Json file that looks like the following. I want to grab the strings of names in the "actors" list and add them to a dataframe (which is empty now, the first item added to the dataframe would be the strings of actor names as rows).
{
"1": {
"title": "Exodus: Gods and Kings",
"url": "https://en.wikipedia.org/wiki/Exodus%3A%20Gods%20and%20Kings",
"year": "2014",
"poster": "https://upload.wikimedia.org/wikipedia/en/thumb/c/cd/Exodus2014Poster.jpg/220px-Exodus2014Poster.jpg",
"actors": [
"Christian Bale",
"Joel Edgerton",
"John Turturro",
"Aaron Paul",
"Ben Mendelsohn",
"Sigourney Weaver",
"Ben Kingsley"
]
},
...
I have tried using the following python code to do this but I am unsuccesful, I beleive because I am using a function wrong or not using the right function at all. Any suggestions as to what function/method to use?
# Create dataframe from json file
df_json = pd.read_json("movies_metadata.json", encoding='latin-1')
# Create new dataframe with actor names
data = [df.iloc[4]]
df = pd.DataFrame(data)
I strongly beleive that my code is very poor, but have had a hard time finding how to do this when googling.
Tried googling all around, as well as different methods from pandas to add items to dataframes