I would really appreciate if someone can explain why this is happening.
I am iterating over a dataframe and saving some information I am gathering online. The information doesn't save if I use df.loc[i]['column']; however, if I use df.column[i], it does! I thought both methods were equivalent, why is this happening?
This is my code:
df=pd.read_excel([ADRESS])
df.['CID']=''
for i in range(df.shape[0]):
info=[GETTINGDATAONLINE]
print('all the data')
print(info)
if info:
df.CID[i]=info[0]['CID']
print('the two following should be the same')
print(info[0]['CID'])
print(df.CID[i])
df.loc[i+1]['CID'] = info[0]['CID']
print('these two should also be the same')
print(info[0]['CID'])
print(df.loc[i+1]['CID'])
This is what I am getting in the console:
all the data
[{'CID': 5280804, 'Synonym': .....]
the two following should be the same
5280804
5280804
these two should also be the same
5280804