Question: Python Pandas Series/Dataframe Question (No loops, No If statement, No List Comprehension) Use the pandas read_csv function to read in the teams and win/loss information.

Python Pandas Series/Dataframe Question (No loops, No If statement, No List Comprehension)

Use the pandas read_csv function to read in the teams and win/loss information. Be sure to label both the indices and the columns in the DataFrame. Return out the DataFrame object in addition to the results in a tuple. A common practice in doing array-based data analysis is to keep metadata separate from the actual numeric data. Metadata consists of items such as field names, descriptions, etc. For example, the file teams.csv (pasted below) contains a list of team names and the file winloss.csv (pasted below) contains information about the teams' records throughout the season. For example, the Owls won their game against the Cubs because line 3, column 5 of the file contains a W. Note the diagonal has X values because teams don't play themselves (obviously!). Write a function named final_results that accepts two parameters: a teams file name and a win/loss file name. If you properly use DataFrame and Series objects, you should be able to return these results (ranked in order of most wins) without using a loop:

In [1]: final_results('teams.csv','winloss.csv') Out[1]: (0 Rams 4 Cubs 3 Jazz 3 Owls 2 Jets 2 Zips 1 dtype: int64,

0 Jazz Jets Owls Rams Cubs Zips Jazz X W W L L W Jets L X W W L L Owls L L X L W W Rams W L W X W W Cubs W W L L X W Zips L W L L L X)

Most of your time on this exercise will likely be spent studying the read_csv documentation page to get an idea for the multitude of options you have to read csv data into pandas. Experiment to find the applicable options.

Find below the file teams.csv:

Jazz
Jets
Owls
Rams
Cubs
Zips

Find below the file winloss.csv:

X W W L L W
L X W W L L
L L X L W W
W L W X W W
W W L L X W
L W L L L X

Point of Stress: This is a Python question requiring that I demonstrate knowledge of Pandas Series/Dataframe. No Loops, No If Statements and No List Comprehension are allowed here. Please attach a print screen in addition to the scripts as evidence the scripts ran properly and as intended. Thanks.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!