0

I try to fill the missing values in Critic Score by grouping 'Name'.

games['Rating'] = dupliacted_games.groupby('Name')['Rating'].apply(
                    lambda x: x.fillna(x.value_counts().idxmax() 
                    if x.value_counts().max() >=1 
                    else mode , inplace = False)
                  )
games['Rating'].fillna(
      dupliacted_games['Rating'].value_counts().idxmax(),inplace=True
)

I get this error :

site-packages\pandas\core\generic.py:6287: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy self._update_inplace(new_data)

Shijith
  • 4,602
  • 2
  • 20
  • 34
Mr_12
  • 23
  • 5
  • 1
    [Please don't upload images of code or errors](https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-errors-when-asking-a-question). Update your question with the error – Ceres Feb 27 '21 at 10:01
  • 1
    not an error but a warning, refer https://stackoverflow.com/questions/20625582/how-to-deal-with-settingwithcopywarning-in-pandas – Shijith Feb 27 '21 at 10:09

1 Answers1

0

It's not an error. You have two ways:

  1. Use pd.DataFrame.copy(deep=True)
  2. Turn off warnings

And always think what you do with your data. Check their size(shape) after groupping, merging e.t.c.

Razor1ty
  • 51
  • 6