Last updated

Inspecting Data

Definition: Before analysing data, you explore it. Pandas has quick methods to preview rows and summarise the whole table.

Example — the essential preview methods

import pandas as pd
df = pd.DataFrame({
  "name":  ["A", "B", "C", "D", "E"],
  "score": [55, 80, 95, 60, 75]
})
print(df.head(2))    # first 2 rows
print(df.tail(2))    # last 2 rows

Statistical summary with describe()

import pandas as pd
df = pd.DataFrame({"score": [55, 80, 95, 60, 75]})
print(df.describe())   # count, mean, min, max, quartiles

The methods you will use daily

  • df.head(n) / df.tail(n) — peek at the top or bottom
  • df.describe() — statistics for numeric columns
  • df.info() — column names, types, and missing-value counts
  • df.shape — quick size check

💡 Tip: always run head() and describe() first on any new dataset — they reveal the shape and quality of your data instantly.

Try it Yourself
Output

          
Ad · responsive