Code Sample, a copy-pastable example if possible
# Your code here
df = pd.read_csv('package_infos.csv')
m = df.shape[0]
df['etags'] = pd.Series(dtype=str, index=range(m))
df['etags'][0] = "Hello world"
Download package_infos.csv from here: https://raw.githubusercontent.com/jamesqo/nuget_recommender/b05ef43a01e54b61851f51708cdd6dce3b2afe33/package_infos.csv
Doing df.loc[0, 'etags'] = "Hello world"
seems to remove the warning, but it's slowing down my app significantly.
Comment From: jamesqo
I forgot to mention, this does not seem to happen if the df
is created manually instead of calling read_csv
.
Comment From: ZhuBaohe
df['etags'] = ' '
df.loc[0, 'etags'] = "Hello world"
Comment From: jreback
this is well documented: http://pandas.pydata.org/pandas-docs/stable/indexing.html#returning-a-view-versus-a-copy
it IS slower because indexing must determie if you are chained indexing, which requires garbage collection (now it normally doesn't even touch this code unless it fails a quick test, where more comprehensive checks happen). so if you avoid chained indexing you won't have a problem.