w3resource

Pandas: Display the first 10 rows of the DataFrame

Pandas: IMDb Movies Exercise-9 with Solution

Write a Pandas program to display the first 10 rows of the DataFrame.

Sample Solution:

Python Code :

import pandas as pd
df = pd.read_csv('movies_metadata.csv')
#Display the first 10 rows
result = df.head(10)
print("First 10 rows of the DataFrame:")
print(result)

Sample Output:

First 10 rows of the DataFrame:
   adult    ...     vote_count
0  False    ...           5415
1  False    ...           2413
2  False    ...             92
3  False    ...             34
4  False    ...            173
5  False    ...           1886
6  False    ...            141
7  False    ...             45
8  False    ...            174
9  False    ...           1194

[10 rows x 24 columns]                                     

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 create a smaller DataFrame with a subset of all features.
Next: Write a Pandas program to sort the DataFrame based on release_date.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Become a Patron!

Follow us on Facebook and Twitter for latest update.

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-9.php