Introduction to Data Science in Python 第 2 周 Assignment

Introduction to Data Science in Python
第 2 周 Assignment

记录下问题和自己的答案

Part 1

The following code loads the olympics dataset (olympics.csv), which was derrived from the Wikipedia entry on All Time Olympic 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.

Question 1

Which country has won the most gold medals in summer games?

This function should return a single string value.

【IN】
def answer_one():
    return df[df['Gold'] == df['Gold'].max()].index[0]

answer_one()
【OUT】
'United States'

Question 2

Which country had the biggest difference between their summer and winter gold medal counts?

This function should return a single string value.

【IN】
def answer_two():
    df['diff'] = abs(df['Gold'] - df['Gold.1'])
    max = df['diff'].max()
    return df[df['diff'] == max].index[0]

answer_two()
【OUT】
'United States'

Question 3

Which country has the biggest difference between their summer gold medal counts and winter gold medal counts relative to their total gold medal count?

S u m m e r   G o l d − W i n t e r   G o l d T o t a l   G o l d \frac{Summer~Gold - Winter~Gold}{Total~Gold} Total GoldSummer GoldWinter 

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值