Question: I'm fairly new to python and working with a DataFrame in pandas & numpy from The Movie Database. One of the columns notes the main
I'm fairly new to python and working with a DataFrame in pandas & numpy from The Movie Database. One of the columns notes the main cast of each movie separated by the pipe symbol (|). I'm trying to find a way to split each individual cast member and list it in its own row with the movie title. I've attached a snippet below of the results I get.
tmdb_data = pd.read_csv('tmdb-movies.csv') cast_split = tmdb_data[['original_title', 'cast']] df = pd.DataFrame(cast_split) df.head()
Expected Output: original_title cast 0 Jursassic World Chris Patt 1 Jursassic World Bryce Dallas Howard 2 Jursassic World Irrfan Khan
original title cast Jurassic World Chris Pratt Bryce Dallas Howardlrrfan KhanlVi... .. Insurgent Shailene Woodley Theo James Kate Winslet/Anse... 3 Star Wars: The Force Awakens Harrison Ford Mark Hamill Carrie Fisher Adam D... 0 Mad Max: Fury Road Tom Hardy Charlize Theron Hugh Keays-ByrnelNic 2 4 Furious 7 Vin Diesel Paul Walker|Jason Statham Michelle
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
