首页 > 解决方案 > 如何仅使用特定列从现有 df 创建新 df

问题描述

我有一个称为匹配的数据框,其中包含以下列: id,season,city,date,team 1,team 2,toss_winner,toss_decision,result,DL_applied winner,win_by_runs,win_by_wickets,player_of_match,venue,umpire 1,umpire 2, umpire 3

从这里我需要创建一个名为matches_compact的新数据框,它应该包含以下列: id, season, date and winner

标签: pandas

解决方案


matches_compact=matches[['id','season','date','winner']]

推荐阅读