# Python Pandas DataFrame Row Count with len() and shape

> Get the number of rows in a Pandas DataFrame using len() for the fastest result or the DataFrame.shape tuple when you also need the column count

**URL:** https://sentry.io/answers/pandas-dataframe-row-count-in-python/

---

## The Problem

How can I get the number of rows of a Pandas DataFrame in Python?

## The Solution

We can do this in one of two main ways:

1. Using Python's built-in [`len()`](https://docs.python.org/3/library/functions.html#len) function:
    ```python
    row_count = len(my_dataframe)
    ```
2. Using the [`DataFrame.shape`](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.shape.html) property, which contains a tuple of the row and column count:
    ```python
    row_count = my_dataframe.shape[0]
    ```

The `len()` function is usually the faster of the two solutions, but `shape` may be useful in circumstances where we also need the column count.

---

*Source: [sentry.io/answers/pandas-dataframe-row-count-in-python/](https://sentry.io/answers/pandas-dataframe-row-count-in-python/)*
