Assignment title: Information


Follow the directions. Use print statements liberally. Comment liberally. Use this format for filenames: _PyHomework2.py (1) Move the show_results.txt file from Blackboard into your project directory. (2) Create 3 lists, one for states, one for shows, and one for viewers. (3) Injest data from text file and put it into a NumPy array (show_results.txt) Itll look like a nested list. ​[ ['Oregon', 'Once Upon a Time', '4075'] [...] …] (4) Print the raw data (5) Take the data from the NumPy array and sort it by state, show and viewers, putting each into the appropriate lists you defined earlier. (so now you have 3 lists, one with states, one with shows and one with viewer counts.) ​No duplicates. ​ So the states list will look like this: ​['Washington', 'Nevada', 'Idaho', 'California', 'Oregon'] (6) Print these unsorted lists (7) Convert all 3 lists into NumPy arrays (8) print new NumPy Arrays (9) Sort the States and Shows arrays Now your States array will look like: ['California', 'Idaho', 'Nevada', 'Oregon', 'Washington'] (10) Convert the Viewers array from STRINGS into INTS (11) Sum up viewers list into one variable (you can do this in one line) (12) Print: Sorted arrays (states and shows), viewers list (as ints), and the variable that is the sum of the viewers list. (13) Create 2 DataFrames: (a)show_raw_stats: index = numpy sorted array of SHOWS; columns = numpy sorted array of STATES (b)show_agg_stats: index = same as above; columns= a list with the words Max, Min, Totals and Percent in it (like this… ['Max','Min','Totals', 'Percent'] (14) Populate show_raw_stats with data from the Original Array injested from show_results.txt. (a)HINT: You will need to create a loop here that basically goes the length of the original array, and on each iteration, it grabs the STATE, SHOW, and VIEWERS number (itll be a string so youll have to convert it…). The final step of each iteration will be placing it in the dataframe in the correct spot as an accumulation. += (Otherwise you just writing over the value there) (Remember the lecture where we used df.ix…) (15) Populate the Max, Min, Totals, and Percent in show_agg_stats using the DataFrame native functionality (see lecture) (16) Print both dataframe (17) Print the answer to these questions: (a)Which Show has the highest percentage? (b)Which Show has the lowest percentage? (c)Which show is your favorite? Extra Points will be given to people whose implementation uses one­line solutions and minimal loop runs.