1 DataFrame插入一行
# 初始化一个空Dataframe
import pandas as pd
data_frame = pd.DataFrame(columns=['f0','f1', 'f2', 'f3','f4','f5','f6','f7', 'f8', 'f9','f10','f11','f12','f13', 'f14', 'f15','f16','f17'],index=[])
# 插入一行,如果需要插入多行,加个for循环即可
singlelist = [0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0]
indexsize = data_frame.index.size
data_frame.loc[indexsize] =singlelist
data_frame.index = data_frame.index + 1
data_frame.to_csv('data_frame.csv',index=False)
DataFrame读取某行
# 读取第一行
data_frame.loc[data_frame.index[0]].values.tolist()
# 读取第二行
data_frame.loc[data_frame.index[1]].values.tolist()