Save grouped by results into separate CSV files

前端 未结 1 1926
时光取名叫无心
时光取名叫无心 2021-01-15 07:44

I have a code for create groups with CSV data and create new files with that groups too!

I read my csv file and then work with that. The problem is when my funtion w

相关标签:
1条回答
  • 2021-01-15 08:22

    You must specify a groupby clause, so pandas knows what to group by. This should work:

    for i, g in df.groupby('Inventory'):
         g.to_csv('{}.csv'.format(i.split('/')[0]), index=False)
    
    0 讨论(0)
提交回复
热议问题