Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

write a python function that will turn those texts(which are strings) showing the show_id, type, title, director, cast, country, date_added, release_year, listed_in, and description: 80058654,TV

write a python function that will turn those texts(which are strings) showing the show_id, type, title, director, cast, country, date_added, release_year, listed_in, and description:

80058654,TV Show,Transformers: Robots in Disguise,,"Will Friedle, Darren Criss, Constance Zimmer, Khary Payton, Mitchell Whitfield, Stuart Allan, Ted McGinley, Peter Cullen",United States,"September 8, 2018",2016,TV-Y7,1 Season,Kids' TV,"When a prison ship crash unleashes hundreds of Decepticons on Earth, Bumblebee leads a new Autobot force to protect humankind." 70299204,Movie,Kidnapping Mr. Heineken,Daniel Alfredson,"Jim Sturgess, Sam Worthington, Ryan Kwanten, Anthony Hopkins, Mark van Eeuwen, Thomas Cocquerel, Jemima West, David Dencik","Netherlands, Belgium, United Kingdom, United States","September 8, 2017",2015,R,95 min,"Action & Adventure, Dramas, International Movies","When beer magnate Alfred ""Freddy"" Heineken is kidnapped in 1983, his abductors make the largest ransom demand in history." ...

into those lists of sublists: where the show_id are an integer, the director name is separate from the cast, but all the cast members are set into one unique string, also if the director, cast element is empty Set to None and if the country element is empty set to Unknown

the date should be formatted as mm-dd-yyyy( an helper function is provided down for that) set to None if empty

the result should be as follow:

[ [80058654, 'TV Show', 'Transformers: Robots in Disguise', None, 'Will Friedle, Darren Criss, Constance Zimmer, Khary Payton, Mitchell Whitfield, Stuart Allan, Ted McGinley, Peter Cullen', 'United States', '09-08-2018', 2016, "Kids' TV", 'When a prison ship crash unleashes hundreds of Decepticons on Earth, Bumblebee leads a new Autobot force to protect humankind.'] , [70299204, 'Movie', 'Kidnapping Mr. Heineken', 'Daniel Alfredson', 'Jim Sturgess, Sam Worthington, Ryan Kwanten, Anthony Hopkins, Mark van Eeuwen, Thomas Cocquerel, Jemima West, David Dencik', 'Netherlands, Belgium, United Kingdom, United States', '09-08-2017', 2015, 'Action & Adventure, Dramas, International Movies', 'When beer magnate Alfred "Freddy" Heineken is kidnapped in 1983, his abductors make the largest ransom demand in history.'], ...]

function to format the date:

def date_cruncher(dirty_date): """ This helper function takes in a raw date string and returns a clean date string in "mm-dd-yyyy" format Parameter: dirty_date (str): uncleaned date string in "Month Day, Year" format Returns: cleaned date (str) in "mm-dd-yyyy" format Example: >>> date_cruncher("September 8, 2018") "09-08-2018" """ date_dict = {"jan":"01", "feb":"02", "mar":"03", "apr":"04", "may":"05", "jun":"06", "jul":"07", "aug":"08", "sep":"09", \ "oct":"10", "nov":"11", "dec":"12"} month, day, year = dirty_date.replace(",", "").split() month = date_dict[month[:3].lower()] day = f"0{day}" if len(day) < 2 else day return f"{month}-{day}-{year}"

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

New Trends In Databases And Information Systems Adbis 2019 Short Papers Workshops Bbigap Qauca Sembdm Simpda M2p Madeisd And Doctoral Consortium Bled Slovenia September 8 11 2019 Proceedings

Authors: Tatjana Welzer ,Johann Eder ,Vili Podgorelec ,Robert Wrembel ,Mirjana Ivanovic ,Johann Gamper ,Mikolaj Morzy ,Theodoros Tzouramanis ,Jerome Darmont

1st Edition

3030302776, 978-3030302771

More Books

Students also viewed these Databases questions

Question

Describe the factors influencing of performance appraisal.

Answered: 1 week ago

Question

What is quality of work life ?

Answered: 1 week ago

Question

How We Listen?

Answered: 1 week ago