pandas 读取 csv 文件的 某一行/列


import pandas as pd 

file = pd.read_csv('', index_col =0)

# 读某一行

# 根据列名

one_row = file.loc ['行名']

#根据索引

one_row = file.iloc [:, i]

# 读某一列

# 根据行名

one_col = file['列名']

# 根据索引

one_col = file.iloc [i,  :]


 

 

你可能感兴趣的:(python)