Pandas: Count the number of rows and columns of the DataFrame
Pandas: IMDb Movies Exercise-4 with Solution
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.
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://198.211.115.131/python-exercises/pandas/movies/python-pandas-movies-exercise-4.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics