A small, complete example of the issue

when i assign a dataframe to part of another dataframe, a warning occured : D:\Program Files\Anaconda3\lib\site-packages\pandas\core\indexing.py:465: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame.

my code like this: df.iloc[:, ::2] = df.iloc[:,::2].fillna(method="ffill", axis=1) this worked ,but there is a warning , so i change the code like this: price = df.iloc[:,::2].copy() price.fillna(method="ffill", axis=1, inplace=True) price.fillna(method="bfill", axis=1, inplace=True) df.loc[:, price.columns.tolist()] = price still work, and still warning.

i'm wonder in the http://pandas-docs.github.io/pandas-docs-travis/indexing.html, there is example: df.loc[:,['B', 'A']] = df[['A', 'B']]

this code is much the same like my code, but there is no warning at all.

i doubt that in my code ,my df is a large dataframe, so maybe somthing i don't know in the low level process of pandas .

# Your code here

Expected Output

Output of pd.show_versions()

# Paste the output here pd.show_versions() here

Comment From: jorisvandenbossche

You will need to provide a full runnable example. It depends on how df is constructed. For example, when df is already a subset of another dataframe, this warning can typically occur.

See http://pandas.pydata.org/pandas-docs/stable/indexing.html#returning-a-view-versus-a-copy for a detailed explanation.

Comment From: jorisvandenbossche

@yangyang1986 I am going to close this issue, but happy to reopen if you can provide a reproducible example!