When I read csv from file, due to the error of the data file, sometimes there will be unnecessary column at the end, so I read them as
df = pd.read_csv(StringIO(all_data_file), skipinitialspace=True, sep=' ', error_bad_lines=False, names = ['stationID', .... ,'unknown'])
Later on I throw the data if the unknow
has data
# Drop if has too many field
df = df[df['unknown'].isnull()]
df.drop('unknown', axis=1, inplace=True)
The problem is that, it gives me error
SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame
So I want to know, what is the proper approach for dropping the data?