In Python, I have a DataFrame that looks like the following, all the way down to about 5000 samples:
I was wondering, in pandas
, how do I remove 3 out of every 4 data points in my DataFrame
?
In Python, I have a DataFrame that looks like the following, all the way down to about 5000 samples:
I was wondering, in pandas
, how do I remove 3 out of every 4 data points in my DataFrame
?
To obtain a random sample of a quarter of your DataFrame, you could use
test4.sample(frac=0.25)
or, to specify the exact number of rows
test4.sample(n=1250))
If your purpose is to build training, validation, and testing data sets, then see this question.
If you want to select every 4th point, then you can do the following. This will select rows 0, 4, 8, ...:
test4.iloc[::4, :]['Accel']