pandas某一列的某一行 .loc

pandas某一列的某一行, choosed列的第i行:

adata.obs['choosed'] = str(0)
for i in range(adata.obs['leiden'].shape[0]):
    id = str(i + 1).zfill(3)
    if adata.obs['leiden'].iloc[i] == ip:
        adata.obs.loc[id, 'choosed'] = str(1)
    else:
        adata.obs.loc[id, 'choosed'] = str(0)

 

Pandas读取某列、某行数据——loc、iloc用法总结_Bigboss7的博客-程序员资料 - 程序员资料

总结的非常全面啊

posted @ 2022-08-23 16:00  bH1pJ  阅读(62)  评论(0编辑  收藏  举报