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.
You have to use parameter k which selects n number of rows randomly.
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.
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 best data science certification.