0

i want to duplicate a column (without a name) in a list of dataframes

for n, df in enumerate(dffinvalues):
    dffinvalues[n] = df.dropna(subset=[1])
    dffinvalues[n][2] = dffinvalues[n][1]

i get a notification from python:

:8: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy dffinvalues[n][2] = dffinvalues[n][1] :8: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy dffinvalues[n][2] = dffinvalues[n][1]

if i check the dataframe it does seem to do what i want. does anyone know what this error means and what to do about it?

Zwink
  • 33
  • 5
  • What is `dffinvalues`? How was it created and what does it contain? If it's doing what you expect it to, you might consider disabling the warning as covered in [this answer](https://stackoverflow.com/a/20627316/15497888) – Henry Ecker Sep 15 '21 at 03:19

0 Answers0