2017년 10월 26일 목요일

csv split by one column values

import pandas

csv = pandas.read_csv('test.csv', sep=',', header=3, skipinitialspace=True)
# header=3 because your header is on the third line
# skipinitialspace is set to True because your example data has spaces after commas
csv_apples = csv[csv['Fruit'] == 'Apple']
csv_bananas = csv[csv['Fruit'] == 'Banana']

csv_apples.to_csv('apples.csv', index=False, sep=',')
csv_bananas.to_csv('bananas.csv', index=False, sep=',')

댓글 없음:

댓글 쓰기

gpustat command

sudo apt install gpustat watch --color -n0.1 gpustat --color