Pandas DataFrame row count in Python

Problem description

How to count rows within pandas DataFrame in Python/

Problem solution

You can use Python's built-in len() function:

count = len(df)

Or you can use the DataFrame.shape property:

count = df.shape[0]

We collect traffic information to improve the site.

Anonymous analytics only. No ads, no cross-site tracking.

Learn more