w3resource

Pandas: Count the number of rows and columns of the DataFrame


Write a Pandas program to count the number of rows and columns of the DataFrame (movies_metadata.csv file).

Sample Solution:

Python Code :

import pandas as pd
df = pd.read_csv('movies_metadata.csv')
result = df.shape
print("Number of rows and columns of the DataFrame:")
print(result)

Sample Output:

Number of rows and columns of the DataFrame:
(50, 24)	                                       

Python-Pandas Code Editor:

Sample Table:


Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a Pandas program to get the details of the third movie of the DataFrame (movies_metadata.csv file).
Next: Write a Pandas program to get the details of the columns title and genres of the DataFrame.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Follow us on Facebook and Twitter for latest update.