Question: Input Output Exercise: (Please answer the exercise in PYTHON code) Part 1 The tollowing code loads the olympics dataset (olympics.csv), which was derrived from the

Input  Input Output Exercise: (Please answer the exercise in PYTHON code) Part
Output
1 The tollowing code loads the olympics dataset (olympics.csv), which was derrived
Exercise:
from the Wikpedia entry on All Time olympkc Games Medals, and does
(Please answer the exercise in PYTHON code)

Part 1 The tollowing code loads the olympics dataset (olympics.csv), which was derrived from the Wikpedia entry on All Time olympkc Games Medals, and does some basic data cleaning The columns are organized as # of Summer games, summer medals # of winter games, Winter medals total # number of games, total # of medals Use this dataset to answer the questions below : import pandas as pd df pd.read_csv('olympics.csv', index col-e, skiprows-1) for col in df.columns: if col[:2]--01' df.rename(columns (col: 'Gold' col[4:]), inplace-True) if col[ : 2-?02 . : df.rename(columns-(col: 'Silver'+col[4:]), inplace-True) if col[:2]--03: oruns-(col: Bronze'icol[4:). Inplace-True) if col[:1]- df.rename(columns-(col:''col[1:]), inplace-True) names_ids -df.index . str. split('\s\(.) # split the index by ,( df. index-names-ids. str[0] # the [0] element df[.ID, ] . names-ids . str[1].str[:3] # the [1] is the country name (new index) element is the abbreviation or ID (take first 3 characters from that) df df.drop( Totals) df.head(O

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!