Python dataFrame 取指定某一行数据
1、按照索引取值
2、找某一列最大值最在行
data=pd.DataFrame({ "company":["A","A","A","A","A","A","A","A","A","A","A","A"], "salary":[10,12,13,36,12,10,12,13,36,12,36,12], "age":[3,1,1,1,1,2,2,1,3,1,11,4] } ) row = data.loc[[0],:]
2、找某一列最大值最在行
idx = data['age'].argmax()
3、求两列差,并新增一列
data["x1"]=data[["salary","age"]].apply(lambda x:x["salary"]+x["age"],axis=1) print(data)