python

dfc = pd.DataFrame({'A':['aaa','bbb','ccc'],'B':[1,2,3]})

dfc.loc[0,'A'] = 11
dfc
Out[347]: 
     A  B
0   11  1
1  bbb  2
2  ccc  3

This can work at times, but is not guaranteed, and so should be avoided

 dfc = dfc.copy()

 dfc['A'][0] = 111

dfc
Out[350]: 
     A  B
0  111  1
1  bbb  2
2  ccc  3
posted @ 2022-08-19 22:59  luoganttcc  阅读(2)  评论(0编辑  收藏  举报