简体   繁体   中英

Converting a split dataframe into csv

I have to split a dataframe containing 15000 rows into sections of 300 rows each.

split_df = np.array_split(data, np.arange(0, len(data),300))

I need to convert the split groups into a dataframe/dataframes and then to be converted to a csv.

Any ideas?

I have one idea.

split_df = np.array_split(data, np.arange(0, len(data),300))
for i in range(len(split_df)):
  csv_writer = split_df[i].to_csv('data'+str(i)+'.csv')

You can use this code to output everything as a csv I hope it fits what you want to do. The only thing is that this code will take some time to finish running. Please be aware of that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM