Randomly Select Rows from Pandas DataFrame
Here are 4 ways to randomly select rows from Pandas DataFrame: (1) Randomly select a single row: Copy df = df.sample() (2) Randomly select a specified number of rows. For example, to select 3 random rows, set n=3: Copy df = df.sample(n=3) (3) Allow a random selection of the same row more than once (by … Read more