Let’s understand random selection of rows from a data set using pandas.
we can use sample method that returns a random sample of items from the dataframe.
df.sample()
You have to use parameter k which selects n number of rows randomly.
df.sample(k=5)
After that, using frac parameter, you can select a fraction of items and select a row. If frac=0.5 then the method returns 50% of rows.
df.sample(frac=0.5)
So, according to you question
You can use df.sample(n=9000)or df.sample(frac=0.25) for to select 9k rows randomly.
If you want to be build successful data science career then enroll for data science certification.