MulaiMulai sekarang secara gratis

The .head() method

It's great to see your data, but most times not all at once. Imagine if you have 10,000 rows printing to the console at once. No good!

To quickly and easily display the first few rows of our data, we can use the .head() method.

Latihan ini adalah bagian dari kursus

Python for Spreadsheet Users

Lihat Kursus

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# Import the pandas package as pd
import pandas as pd

# Read in the Excel file
sales = pd.read_excel('ticket_sales.xlsx')

# Print first 5 rows of the DataFrame
print(sales.____())
Edit dan Jalankan Kode