In this article, we’ll see how we can get the count of the total number of rows and columns in a Pandas DataFrame. There are different methods by which we can do this. Let’s see all these methods with the help of examples.
Example 1: We can use the
dataframe.shape to get the count of rows and columns.
dataframe.shape gives count of rows and columns respectively.
Example 2 : We can use the
len() method to get the count of rows and columns.
dataframe.axes represents rows and
dataframe.axes represents columns. So,
dataframe.axes gives the count of rows and columns respectively.
Example 3 : Similar to the example 2,
dataframe.index represents rows and
dataframe.columns represents columns. So,
len(dataframe.columns) gives count of rows and columns respectively.
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.
- Count the number of rows and columns of a Pandas dataframe
- Get the number of rows and number of columns in Pandas Dataframe
- Dealing with Rows and Columns in Pandas DataFrame
- Iterating over rows and columns in Pandas DataFrame
- How to create an empty DataFrame and append rows & columns to it in Pandas?
- Find maximum values & position in columns and rows of a Dataframe in Pandas
- Python | Delete rows/columns from DataFrame using Pandas.drop()
- Drop rows from Pandas dataframe with missing values or NaN in columns
- Apply a function to single or selected columns or rows in Pandas Dataframe
- Sort rows or columns in Pandas Dataframe based on values
- Get minimum values in rows or columns with their index position in Pandas-Dataframe
- Select Rows & Columns by Name or Index in Pandas DataFrame using [ ], loc & iloc
- Find duplicate rows in a Dataframe based on all or selected columns
- Count number of columns of a Pandas DataFrame
- Count the NaN values in one or more columns in Pandas DataFrame
- Count all rows or those that satisfy some condition in Pandas dataframe
- Display the Pandas DataFrame in table style and border around the table and not around the rows
- Select first or last N rows in a Dataframe using head() and tail() method in Python-Pandas
- How to select multiple columns in a pandas dataframe
- How to drop one or multiple columns in Pandas Dataframe
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.