I want to combine 2 file CSV data, but not all data. e.g: a.csv + b.csv, where b.csv have 20 data. But I want to take only 10 data from that, and then take 11-20 data. Or the first 10 and the second 10
Then insert the first 10 data into a.csv, and the second 10 data into a.csv too My Question is how can I take only specific total data?
Here is my code:
import pandas as pd
df1 = pd.read_csv('testNegatif.csv')
df2 = pd.read_csv('trainNegatif.csv', nrows=10)
output=df1.append(df2)
output.to_csv("output.csv", sep=',')
I expect the result return that I want, but the actual result is combining all data.
As mentioned in my comment, you can use nrows
import pandas as pd
df1 = pd.read_csv('testNegatif.csv')
df2 = pd.read_csv('trainNegatif.csv', nrows=10)
output=df1.append(df2)
output.to_csv("output.csv", sep=',')
See: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_csv.html for more options