我有一个包含1738行的数据框。我想创建由这些行组成的1738个数据帧,并保持列标题相同。我该怎么办?
如果原始数据帧是data
column_list = data.columns.tolist() #get column names as list
for index,row in data.iterrows(): #iterate through rows
new_df = pd.DataFrame(columns=column_list) #make new dataframe
new_df = new_df.append(pd.Series(row,index = column_list),ignore_index = True) #insert the row in newdataframe
new_df.to_excel(str(index)+".xlsx") #output newdf as rownumber
这应该完成工作。