Menu

Pandas Basics for Data Handling

Pandas Basics for Data Handling

Pandas is a Python library for loading, exploring, and manipulating structured data, like spreadsheets or CSV files, making it essential for any machine learning project.

Creating a DataFrame

A DataFrame is like a table, with rows and columns, and it is the main structure used in Pandas.

import pandas as pd

data = {

    "Name": ["Alex", "Sam", "Riya"],

    "Score": [85, 90, 78]

}

df = pd.DataFrame(data)

print(df)

Reading a CSV File

Most real-world datasets come as CSV files, and Pandas makes them easy to load.

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

print(df.head())

Exploring Data

Before building any model, you need to understand your dataset's structure and basic statistics.

print(df.info())

print(df.describe())

print(df.shape)

Selecting Columns and Rows

You can access specific parts of your data by column name or row position.

print(df["Score"])

print(df.iloc[0])

Filtering Data

Filtering helps you extract only the rows that meet a certain condition.

high_scorers = df[df["Score"] > 80]

print(high_scorers)

Pandas lets you clean, explore, and prepare real-world data quickly, which is why it is used in almost every machine learning project before building any model.


Machine Learning Tutorial

AP

Abhishek Pati



Learn via Video Course

Artificial Intelligence and Machine Learning Course Logo

Artificial Intelligence and Machine Learning Course

55 hrs



Get in Touch For Details