I'm currently working on a project on python with jupyter notebook. I would like to predict stadium attendance in france (ligue 1).
To achieve that I have taken data from web with beautiful soup. I'm trying now to clean up my data : I have some missing values for the stadiums and I would like to assign stadium for a specific team (Olympique lyonnais).
I first tried that :
stats_match.stade[(stats_match.saison >= 2017) & (stats_match.domicile == 'Olympique Lyonnais') & (stats_match.stade.isna())] = 'Groupama stadium'
which gave me that error :
SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame
So I followed the instruction and tried that :
stats_match.stade.loc((stats_match.saison >= 2017) & (stats_match.domicile == 'Olympique Lyonnais') & (stats_match.stade.isna())) = 'Groupama stadium'
which give me :
File "", line 3 stats_match.stade = stats_match.stade.loc((stats_match.saison >= 2017) & (stats_match.domicile == 'Olympique Lyonnais') & (stats_match.domicile.isna())) = 'Groupama stadium'
SyntaxError: can't assign to function call
What do I miss here ? Do I have to use .where function ? Many thanks
.locuses square brackets, not.loc()locallows you to specify the column that you want to transform, separated from your conditions by a comma but still inside the square brackets