Pandas reads DataFrame data row by row and modifies corresponding data

Read the data line by line and modify the corresponding data

	# remove_data,为一个DataFrame对象
    for indexs in remove_data.index:
        # 逐行查看,values可以用int型索引
        remove_data.loc[indexs].values[0:-1]
 
        # 逐行修改列值
        remove_data.loc[indexs, "Norm_peptide"] = norm_protein
        
		# 也可以用loc方法查看指定元素
		remove_data.loc[indexs].values[10]

delete

	# data为DataFrame对象
	# Gene_ID是data的列索引值
	# not_ensenbl是存储Gene_ID的列表
    res= data[~data.Gene_ID.isin(not_ensembl)]

Guess you like

Origin blog.csdn.net/qq_41292236/article/details/108049943
Recommended