开课吧--Python数据分析--第4节 数据七十二变--互动练习:如果你不需要,就让它消失!

题目要求
从自2009-2010赛季以来的英格兰当地足球比赛结果数据中,删除2009/2010赛季的所有数据以及county列。
文件路径为./data/sccore_game.xlsx
题目讲解

名词解释

  • game_date-比赛时间
  • country-国家
  • tournament-锦标赛
  • season-赛季
  • home_field-主场场地
  • home_team-主场球队
  • away_team-客场球队
  • home_team_score-主场球队得分
  • away_team_score-客场球队得分
  • home_team_score_extra_time-主持球队加时赛
  • away_team_score_extra_time-客场球队加时赛

书写代码

 

import pandas as pd

df = pd.read_excel('./data/sccore_game.xlsx')

df.drop(labels=df[df['season']=='2009/2010'].index.tolist(),inplace=True)

# mylist = df[df['season']=='2009/2010'].index.tolist()

# df.drop(labels=mylist,axis=0,inplace=True)

df.drop(columns='country',inplace=True)

posted @ 2020-09-13 20:27  李思爱学习  阅读(149)  评论(0编辑  收藏  举报