Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 image text in transcribed
Output
image text in transcribed
Exercise:
image text in transcribed
(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

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_2

Step: 3

blur-text-image_3

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

Practical Database Programming With Visual C# .NET

Authors: Ying Bai

1st Edition

0470467274, 978-0470467275

More Books

Students also viewed these Databases questions

Question

What is a safety margin?

Answered: 1 week ago