Basic Functionalities of a Data Object

Whether you're working with a Series or a DataFrame, Pandas gives you a common set of built-in functionalities to quickly inspect, summarise, and understand your data before doing any real analysis.

Taking a First Look

import pandas as pd

df = pd.read_csv("students.csv")

print(df.head(3))    # first 3 rows
print(df.tail(3))    # last 3 rows
print(df.sample(2))  # 2 random rows

Structural Information

print(df.shape)    # (rows, columns)
print(df.info())   # column names, non-null counts, dtypes
print(df.dtypes)   # data type of each column

Statistical Summary

print(df.describe())     # count, mean, std, min, max for numeric columns
print(df["Score"].mean())
print(df["Score"].max())
print(df["Score"].value_counts())   # frequency of each unique value

Sorting Data

print(df.sort_values("Score", ascending=False))
print(df.sort_index())
Running df.info() and df.describe() as the very first step on any new dataset is one of the most reliable habits in data analysis - it immediately tells you column types, missing values, and the general shape of your numbers.

Coming Up Next

Next, you'll learn how to combine data from multiple DataFrames using merging.

Ready to Master Data Science?

Join Uncodemy's Data Science Course and build real, job-ready skills with expert mentors.

Explore Course