I have a csv file. I am using it to do some machine learning stuffs on it. But, my dataset in csv file is very large. For doing some practice stuffs, I want to reduce its size. Like, in my original csv file, I have 200000 data items. But for practice I want to create a csv file with first 100 data items. How can I do this with python.
Note: I want a new csv file of 100 data items.
I tried using to_csv method of pandas library.
x.to_csv('tempo.csv', sep='\t', encoding='utf-8')
The above method made a new file. But, it gives me error for following code:
x['Keywords']=x['Keywords'].map(lambda x: convert(x))
Error is:
SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
x['Keywords']=x['Keywords'].map(lambda x: convert(x))