我有一个数据集,包含足球队和得分
我在寻找连续几次在比赛中进球少于1.5球的记录
我做到了:
import pandas as pd
df = pd.read_csv('https://www.football-data.co.uk/mmz4281/1920/F1.csv')
dh = df[['Date','HomeTeam','AwayTeam','FTHG','FTAG']]
# for all the match of one team
index_list = dh[(dh['HomeTeam'] == 'Paris SG') | (dh['AwayTeam'] == 'Paris SG')].index.tolist()
dh_psg = dh.iloc[index_list]
print(dh_psg)
以下是我正在寻找的一个例子:
这是有史以来打破纪录的连胜
Date HomeTeam AwayTeam FTHG FTAG
5 7/08/2019 Montpellier Rennes 0 1
11 10/08/2019 Nantes Montpellier 0 0
14 12/08/2019 Montpellier Paris SG 1 0
16 14/08/2019 Toulouse Montpellier 1 0
18 18/08/2019 Montpellier Strasbourg 0 0
print("the record-breaking streak of all time is", 5)
2-考虑到最后的日期,这是本书的破纪录续集
Date HomeTeam AwayTeam FTHG FTAG
17 19/08/2020 Montpellier Dijon 1 0
18 22/08/2020 Montpellier Strasbourg 0 0
print("the record-breaking sequel to by taking into account the last date is", 2)
谢谢你的帮助
使用
lt
和agg
:输出:
相关问题 更多 >
编程相关推荐