1. Learn
  2. /
  3. Courses
  4. /
  5. Reshaping Data with pandas

Connected

Exercise

Nested movies

You are curious about a movies dataset you've had on your computer for some time now that contains data about different movies. You would like to analyze that data, but you realize it's in a nested JSON format.

To read it into a DataFrame, you will need to use the function you have just learned. After that, you will reshape the resulting DataFrame to make it easier to work with.

The semi-structured JSON named movies is available for you. Make sure to examine it in the console!

Instructions

100 XP
  • Import the json_normalize() function from pandas.
  • Normalize the JSON contained in movies. Separate the names generated from nested records with an underscore.
  • Reshape the resulting movies_norm DataFrame from wide to long format, using the director and producer columns as unique indexes. Name the new variable created from the columns movies, starting with features, separated by an underscore with a suffix containing words.