You can get the row count of a Pandas DataFrame using the shape attribute or the len() function.
Here's an example using the shape attribute:
import pandas as pd
# create a sample DataFrame
df = pd.DataFrame({'name': ['Alice', 'Bob', 'Charlie'], 'age': [25, 30, 35]})
# get the row count
row_count = df.shape[0]
print(row_count) # Output: 3
Here's an example using the len() function:
import pandas as pd
# create a sample DataFrame
df = pd.DataFrame({'name': ['Alice', 'Bob', 'Charlie'], 'age': [25, 30, 35]})
# get the row count
row_count = len(df)
print(row_count) # Output: 3
Both methods will return the same output, which is the number of rows in the DataFrame.
Comments (0)