0% found this document useful (0 votes)
15 views

Pandas

The document provides an overview of the Pandas library and its use in data analysis and AI projects. It covers Pandas fundamentals like Series and DataFrames, data cleaning, manipulation, grouping, aggregation, visualization, and handling Excel files. Real-world examples of analyzing sales, sensor, and social media data with Pandas are also discussed.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Pandas

The document provides an overview of the Pandas library and its use in data analysis and AI projects. It covers Pandas fundamentals like Series and DataFrames, data cleaning, manipulation, grouping, aggregation, visualization, and handling Excel files. Real-world examples of analyzing sales, sensor, and social media data with Pandas are also discussed.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 28

Pandas – Step by Step

Journey
Introduction to Pandas
• Pandas overview: A powerful Python library for data
manipulation and analysis.

• Real-world example: Analyzing sales data from an e-


commerce website to identify trends and customer behavior.

• Importance in AI: Pandas facilitates data prepossessing tasks


essential for building machine learning models.
PANDAS INSTALLATION
INSTALL PANDAS USING PIP
PIP is a package management system used to install and manage software packages/libraries
written in python. these files are stored in a large “online repository” termed as python package
index (pypi).
STEP 1: Open command prompt
INSTALLATION CONTINUES…...

Pandas can be installed using PIP by use of the following command in Command Prompt.
pip install pandas
Series and DataFrames

• Explanation of Series and Dataframes as fundamental data


structures in Pandas.

• Real-world example: Using a DataFrame to organize and


analyze sensor data collected from IoT devices in smart
homes.

• Understanding Series and DataFrames is crucial for handling


and processing datasets in AI projects.
Series and DataFrames
Add a New Column to an Existing Datframe using DataFrame.insert()

import pandas as pd

# Define a dictionary containing Students data


data = {'Name': ['Jai', 'Princi', 'Gaurav', 'Anuj'],
'Height': [5.1, 6.2, 5.1, 5.2],
'Qualification': ['Msc', 'MA', 'Msc', 'Msc']}

# Convert the dictionary into DataFrame


df = pd.DataFrame(data)

# Using DataFrame.insert() to add a column


df.insert(2, "Age", [21, 23, 24, 21], True)
Adding Columns to Pandas DataFrame using Dataframe.assign()

import pandas as pd

# Define a dictionary containing Students data


data = {'Name': ['Jai', 'Princi', 'Gaurav', 'Anuj'],
'Height': [5.1, 6.2, 5.1, 5.2],
'Qualification': ['Msc', 'MA', 'Msc', 'Msc']}

# Convert the dictionary into DataFrame


df = pd.DataFrame(data)

# Using 'Address' as the column name and equating it to the list


df2 = df.assign(address=['Delhi', 'Bangalore', 'Chennai', 'Patna'])
Data Exploration and Inspection

• Methods for exploring and inspecting data: head(), tail(),


info(), describe().

• Real-world example: Using describe() to generate summary


statistics for a dataset containing housing prices.

• Data exploration helps AI students understand the


characteristics and distributions of data.
Indexing and Selection

• Accessing elements using .loc[] and .iloc[] for row and


column selection.

• Real-world example: Extracting specific rows and columns


from a DataFrame containing weather data for analysis.

• Understanding indexing and selection is crucial for data


manipulation and feature selection in AI projects.
Indexing and Selection
Indexing and Selection
Data Cleaning and Handling Missing
Values
• Techniques for handling missing data: dropna(), fillna().

• Real-world example: Cleaning a dataset of patient records by


removing or imputing missing values before analysis.

• Data cleaning ensures the quality and integrity of data used


in AI algorithms.
Data Cleaning and Handling Missing
Values
Data Manipulation and Transformation

• Applying functions to data: apply(), map(), applymap().

• Real-world example: Converting temperature values from


Fahrenheit to Celsius using apply() on a DataFrame column.

• Data manipulation and transformation are essential for


feature engineering in AI model building.
Data Manipulation and Transformation
Grouping and Aggregation

• Grouping data using groupby() for statistical analysis and


aggregation.

• Real-world example: Grouping customer purchase data by


product category to calculate total sales revenue.

• Grouping and aggregation help derive meaningful insights


from data in AI-driven business decisions.
Grouping and Aggregation
Visualization with Pandas

• Plotting data directly from DataFrames using plot() for visual


analysis.

• Real-world example: Visualizing trends in temperature data


over time using line plots generated from a DataFrame.

• Data visualization aids in understanding patterns and


relationships in data for AI model interpretation.
Visualization with Pandas
Visualization with Pandas
Reshaping and Pivoting Data

• Reshaping data using pivot() and melt() for restructuring


datasets.

• Real-world example: Pivoting customer transaction data to


analyze purchase patterns and customer behavior.

• Reshaping data facilitates data aggregation and analysis in


AI-driven business insights.
Reshaping and Pivoting Data
Handling Excel Files with Pandas

• Reading and writing Excel files with Pandas: read_excel(),


to_excel().

• Real-world example: Importing financial data from Excel


spreadsheets for analysis and forecasting.

• Handling Excel files enables seamless integration of external


data sources in AI projects.
Case Study: Analyzing Customer Data

• Applying Pandas techniques to analyze customer behavior


and preferences.

• Real-world example: Analyzing e-commerce sales data to


identify customer segments and personalize marketing
strategies.

• Case studies provide practical insights into applying Pandas


skills in real-life AI projects.
Case Study: Social Media Analytics

• Leveraging Pandas for analyzing social media engagement


metrics and trends.

• Real-world example: Analyzing Twitter data to measure


brand sentiment and track campaign performance.

• Social media analytics with Pandas helps businesses


optimize marketing strategies and brand perception in AI-
driven digital marketing.
Good Luck!!

Thanks

You might also like