-1

I tried renaming an index value with the code:

df_1.rename({'*****': "Favour Edwards"}, axis = 0, inplace = True)

and I got this message:

/home/jupyterlab/conda/envs/python/lib/python3.6/site-packages/pandas/core/frame.py:4238: 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
  return super().rename(**kwargs)

Although my code still ran without any observable errors, i still checked out the link but unfortunately i'm still pretty new with coding and the vocabulary/ semantics of the documentation seemed sort of complex for me to really understand. Anyone who can break down the meaning in simpler terms?

roganjosh
  • 12,594
  • 4
  • 29
  • 46
nachi
  • 1
  • 1
  • 1
    This is a clear dupe. But no amount of explanation has made me properly understand this warning; it's spurious in so many cases – roganjosh Nov 08 '19 at 19:32
  • The warning says that `df_1` is a slice of a bigger dataframe. You can't/shouldn't rename it inplace. – Quang Hoang Nov 08 '19 at 20:09
  • Thanks for the contribution. I'd simply set **is_copy** flag to **False** to turn off the check for the object as suggested via the link @roganjosh shared. – nachi Nov 09 '19 at 20:36

1 Answers1

-1

Its a WARNING not ERROR (big distinction) that your operation may not have worked as expected and that you should check the results.

RustyShackleford
  • 3,462
  • 9
  • 40
  • 81