PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteUse df.head(10) to get the first ten rows of a pandas DataFrame. In a Python script, print the result with print(df.head(10)); in a notebook, enter df.head(10) in a cell to display it.
Print the first 10 rows
The head method returns a DataFrame containing rows from the beginning of the DataFrame’s current order. Pass 10 to request ten rows:
As an Amazon Associate I earn from qualifying purchases.
print(df.head(10))
For example:
import pandas as pd
df = pd.DataFrame({
"name": ["Ava", "Ben", "Chen", "Dia", "Eli", "Fatima", "Gus", "Hana", "Ivan", "Jo"],
"score": [91, 84, 88, 95, 79, 93, 86, 90, 82, 97],
})
print(df.head(10))
The result includes the existing index labels and columns; head does not reset the index.
What if the DataFrame has fewer than 10 rows?
df.head(10) returns every row that is available if the DataFrame contains fewer than ten. If it has no rows, the result is an empty DataFrame.
#1 Best Overall
Why specify 10?
Calling df.head() without an argument returns five rows by default. Include 10 when you specifically want ten.
Does head(10) sort the data?
No. It selects rows by position from the current order; it neither sorts rows nor selects them by index label. To inspect the ten lowest values in a column, sort by that column or use a value-oriented method such as nsmallest.
Rank #2
Related ways to preview rows
df.tail(10)previews rows from the end.df[:10]is equivalent todf.head(10)for a positive row count.
A preview only shows the beginning of the current data. It does not establish that every row is valid; for example, inspect dtypes when you need to check column data types.
These behaviors are documented in the pandas 3.0.6 DataFrame.head reference and the pandas basics guide.
Quick Recap
Best Value
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




