AttributeError: 'DataFrame' object has no attribute 'row_count'

I’m having some trouble getting the row count of a Pandas DataFrame using Python. I’m pretty new to Pandas, so I’m not sure what I’m doing wrong.

Here’s the code I have:

When I run this code, I get the following error message:
AttributeError: 'DataFrame' object has no attribute 'row_count'

I’m not sure what’s causing this error or how to get the row count of the DataFrame. I’ve tried looking up solutions online, but I haven’t found anything that’s working for me. Can someone please help me figure out what’s going wrong and how to fix it?

To correct your code, you should replace df.row_count() with df.shape[0] to get the number of rows in the DataFrame. The shape attribute returns a tuple representing the dimensionality of the DataFrame, where the first element is the number of rows and the second is the number of columns.

import pandas as pd

df = pd.DataFrame({
    'name': ['Alice', 'Bob', 'Charlie', 'Dave'],
    'age': [25, 32, 18, 47],
    'gender': ['F', 'M', 'M', 'M']
})

num_rows = df.shape[0]
print(num_rows)