dimanche 18 novembre 2018

Selecting random rows (of data) from dataframe / csv file in Pyhton after designating start and end row number?

Using the sample() function I can get the random rows. Data set having 1000000 rows of data and I want to have a subset of 20000 rows. importing random lines can be done through this solution https://stackoverflow.com/a/22259008/8966221

reading a dataset

dataset = read_csv(file_path)

dataset_sub = dataset.sample(20000, random_state=1)

However I want to select random rows between row number 250000 to 750000. Any possible solution in that regard?




Aucun commentaire:

Enregistrer un commentaire