Question
Need a help in completing the following function in python where it says write Solution Here. 1- first question is to read only the first
Need a help in completing the following function in python where it says "write Solution Here".
1- first question is to read only the first 100 data rows in the table. below given code reads all the rows from movies.csv
2- second question is to sort this table in descending order of the values in the last (3rd) column (column name is Avg). Note that this column needs to be returned as a string but sorting may require float casting
Snap shot of the movie table is provided.
---------------------------------------------------------------------------------------------------
def data_wrangling(): with open('data/movies.csv', 'r', encoding='utf-8') as f: reader = csv.reader(f) table = list() # Feel free to add any additional variables ... # Read in the header for header in reader: break # Read in each row for row in reader: table.append(row) # Only read first 100 data rows
"write solution here"
... # Order table by the last column
"write solution here" ... return header, table
Movies ID Tltle Avg 11 Star Wars 76.496 62 2001 : A Space Odyssey 39.064 152 Star Trek: The Motion Picture 26.551 154 Star Trek 11: The Wrath of Khan 17.266 157 Star Trek iii: The Search for Spock 17.008 168 Star Trek 1 V: The Voyage Home 17.747 172 Star Trek V: The Final Frontier 18.588 174 Star Trek Vi: The Undiscovered Country 10.975 193 Star Trek: Generations 10.921 199 Star Trek: First Contact 22. 78 200 Star Trek: Insurrection 17.369 201 Star Trek: Nemesis 22.021 212 Arsenic and Old Lace 12.55 411 The Chronicles of Narnia: The Lion, the Witch and the Wardrobe 31.61 563 Starship Troopers 22.141 679 Aliens 29.666 935 Dr. Strangelove or: How I Learned to Stop Worrying and Love the Bomb 21.628 940 The Lady Vanishes 14.034 1410 Dark Star 8.462 1771 Captain America: The First Avenger 25.99 1884 The Ewok Adventure 11.998 1891 The Empire Strikes Back 27.13 1892 Return of the Jedi 24.305 1893 Star Wars: Episode | - The Phantom Menace 28.646 1894 Star Wars: Episode II - Attack of the Clones 25.394 1895 Star Wars: Episode III - Revenge of the Sith 27.07 2102 Solar Crisis 4.675 2115 Light of Day 3.617 2164 Stargate 21.584 2215 Star-Crossed Lovers 1.049Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started