pandas 遍历 dataframe 行数据

import pandas as pd
inp = [{'c1':10, 'c2':100}, {'c1':11,'c2':110}, {'c1':12,'c2':120}]
df = pd.DataFrame(inp)
print(df)

# pandas 遍历 dataframe 行数据
for index, row in df.iterrows():
    print(index,row[0],row[1],)

# pandas 遍历 dataframe 列数据
for x in df.loc[:,'c1']:
    print(x)

posted on 2020-07-14 11:23  耀扬  阅读(3590)  评论(0编辑  收藏  举报

导航