
Problem –
You have a pandas dataframe and you want to know how many rows of data you have in that dataframe.
Solution –
There are many ways finding the number of rows in a pandas dataframe. Let’s read a dataset to illustrate.
import pandas as pd
df = pd.read_csv('https://raw.githubusercontent.com/bprasad26/lwd/master/data/Restaurant.csv')
df.head()

To know the number of rows in a pandas dataframe, we can use the dataframe.shape attribute. The dataframe.shape attribute returns a tuple of the number of rows and columns in a dataframe (nrows, ncolumns).
df.shape
out - (300, 3)
This dataframe has 300 rows and 3 columns. If you only want the rows or the columns then you can write like this.
# get me only rows count
df.shape[0]
# get me only column counts
df.shape[1]
Another method for finding the number of rows in a dataframe is using the len() function in python.
len(df)
out - 300