Why can't I call the sum() twice?

Viewed 84

I have this line of code:

feat_table.at(i, 'pastHC')=(ht_stats[ht_stats["AwayTeam"] == ht].sum().HC + ht_stats[ht_stats["HomeTeam"] == ht].sum().HC)/k

However, when I run the cell on Jupyter, it gives me the error:

cannot assign to function call

and it points to the second sum() function in the line of code.

1 Answers

Don't use at, you can't assign values with at, try using loc:

feat_table.loc[i, 'pastHC'] = (ht_stats[ht_stats["AwayTeam"] == ht].sum().HC + ht_stats[ht_stats["HomeTeam"] == ht].sum().HC) / k
Related