Random sampling is a process of selecting values from a data sample at random positions. From pandas 0.19.2 on, this functionality has been added to the pandas Series and DataFrame objects, whereas in previous versions, you had to code this process on your own.
To demonstrate random sampling, let's start with the following DataFrame, representing four columns of 50 rows of random numbers:
We can take a sample of the data using the .sample() method while specifying the number of samples to retrieve. The following code samples three random rows:
An alternative form is to specify a percentage of the data to ...