Here is a dataframe that we can import with import pandas as pd; df=pd.clipboard().
Index Unnamed: 1 HLA A1_D HLA A2_D HLA B1_D HLA B2_D HLA C1_D HLA C2_D DRB11_D DRB12_D DQB11_D DQB12_D Unnamed: 12 HLA A1_R HLA A2_R HLA B1_R HLA B2_R HLA C1_R HLA C2_R DRB11_R DRB12_R DQB11_R DQB12_R
1 A*01:01 A*32:01 B*38:01 B*44:02 C*05:01 C*12:03 DRB1*04:01 DRB1*04:02 DQB1*03:02 DQB1*03:02 A*01:01 A*32:01 B*38:01 B*44:02 C*05:01 C*12:03 DRB1*04:01 DRB1*04:02 DQB1*03:01 DQB1*03:02
2 A*24:02 A*30:01 B*07:02 B*13:02 C*06:02 C*07:02 DRB1*04:05 DRB1*15:01 DQB1*03:02 DQB1*06:02 A*24:02 A*30:01 B*07:02 B*13:02 C*06:02 C*07:02 DRB1*04:04 DRB1*15:01 DQB1*03:02 DQB1*06:02
When I do
df_dddd = df.filter(regex='_D')
and then
df_dddd.drop([1], axis=0, inplace=True)
I get the following warning:
<input>:1: SettingWithCopyWarning:
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've read the documentation, but I don't understand how it applies to me. df_ddddd is a slice from a DataFrame, but it's been put into a variable so it should be enough for pandas to understand that it's not "just" a slice from a DataFrame anymore, right?