Let us see how to shuffle the rows of a DataFrame. We will be using the sample() method of the pandas module to randomly shuffle DataFrame rows in Pandas.
Example 1 :
Example 2 :
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- Pandas - How to shuffle a DataFrame rows
- Get all rows in a Pandas DataFrame containing given substring
- Convert given Pandas series into a dataframe with its index as another column on the dataframe
- Python | Delete rows/columns from DataFrame using Pandas.drop()
- How to randomly select rows from Pandas DataFrame
- How to get rows/index names in Pandas dataframe
- Different ways to iterate over rows in Pandas Dataframe
- Selecting rows in pandas DataFrame based on conditions
- How to iterate over rows in Pandas Dataframe
- Sorting rows in pandas DataFrame
- Dealing with Rows and Columns in Pandas DataFrame
- Iterating over rows and columns in Pandas DataFrame
- Ranking Rows of Pandas DataFrame
- Create a list from rows in Pandas dataframe
- Create a list from rows in Pandas DataFrame | Set 2
- How to Drop Rows with NaN Values in Pandas DataFrame?
- Drop rows from Pandas dataframe with missing values or NaN in columns
- How to drop rows in Pandas DataFrame by index labels?
- Get the number of rows and number of columns in Pandas Dataframe
- How to create an empty DataFrame and append rows & columns to it in Pandas?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.