I am renaming a column in a pandas df, but get the error "A value is trying to be set on a copy of a slice from a DataFrame. See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy".
I am aware of this error message - a classic. I thought I had understood what causes this error. However, I am confused why this would pop up in this context. I do not see how I would (mistakenly) work on a copy... I am using the column rename function as follows:
match_stats_home_team.rename(columns={"Game Day ID":"Team Day ID"},inplace=True)
The column "Game Day ID" should be, and is, in fact, renamed into "Team Day ID". What am I doing wrong, and how would "good" code look like?