May-25-2019, 11:28 AM

Thanks that sorted out the season problem! Yeah you are right, season is what matters actually. However year equeals season in this case.

I realised i did i stupid mistake in my example, i only displayed part of the datafrme showing just two teams. There are more teams (Orebro, Norrkoping and so on..) so in full dataframe the points doesn't calculate correct. I think i can sort this out by myself though.

For example i replace

I havn't quite figured out how to change

Agian, big thanks for the time and the help! :)

I realised i did i stupid mistake in my example, i only displayed part of the datafrme showing just two teams. There are more teams (Orebro, Norrkoping and so on..) so in full dataframe the points doesn't calculate correct. I think i can sort this out by myself though.

For example i replace

draws = (df['Result']=='D').where(df['Year'] == year)with

hd = (df['Result'] == 'D').where((df['H_team'] == team_1) & (df['Year'] == year)) ad = (df['Result'] == 'D').where((df['H_team'] == team_1) & (df['Year'] == year))and on line 35, 36 i replace "draws" with "hd" and "ad"

I havn't quite figured out how to change

df['H_points'] = df['H_points'].add(team_1_points.where(df['H_team'] == team_1, team_2_points), fill_value=0) df['A_points'] = df['A_points'].add(team_1_points.where(df['A_team'] == team_1, team_2_points), fill_value=0)to handle more teams yet, but i guess i need extend the where condition?

Agian, big thanks for the time and the help! :)