SlideShare a Scribd company logo
Python with AI – 2
Session 2
Pandas - Dataframe
• Pandas is useful and important for reading CSV files, the datasets
used for training models
Pandas - Dataframe
• Pandas is useful and important for reading CSV files, the datasets
used for training models
Pandas - Dataframe
• Pandas is useful and important for reading CSV files, the datasets
used for training models
Pandas - Dataframe
• Concept of index in a dataframe
Index
Pandas - Dataframe
• Types of columns in dataframes
Pandas - Dataframe
• Access elements of a dataframe
Interpreting CSV Data - Properties
• len() - Returns the total amount of rows
• shape - Returns an object which contains the total number of rows and
columns
• head(n) - Retrieves the top n (Integer) rows
• info() - Displays all columns and their data types
• dtypes() - Retrieves the column title and its respective data type
• columns – Retrieves the column names
Sorting CSV Files - Methods
• Multiple different methods to sort columns and values
• sort_values() - sorting the DataFrame by one or more columns
• sort_index() - sorting the DataFrame by the row index
import pandas
nbaDataFrame = pd.read_csv("NBA_CSV_DATA.csv")
nbaDataFrame.sort_values(parameters)
nbaDataFrame.sort_index(parameters)
Exploring CSV File Data - Value
• Sorting columns by given player weight (decreasing to increasing)
import pandas
nbaDataFrame = pd.read_csv("NBA_CSV_DATA.csv")
sortedDataFrame = nbaDataFrame.sort_values('Weight',
ascending=True)
print sortedDataFrame[['Weight', 'Name']]
Exploring CSV File Data Output
Note* : Values are
sorted by row
index when values
are equal for
given sorting
factor.
Pandas- Methods
• Creating a dataframe from scratch
Sorting CSV Files - Methods
• Multiple different methods to sort columns and values
• sort_values() - sorting the DataFrame by one or more columns
• sort_index() - sorting the DataFrame by the row index
import pandas
nbaDataFrame = pd.read_csv("NBA_CSV_DATA.csv")
nbaDataFrame.sort_values(parameters)
nbaDataFrame.sort_index(parameters)
Exploring CSV File Data Output
Note* : Values are
sorted by row
index when values
are equal for
given sorting
factor.
Exploring CSV File Data - Value
• Sorting columns by given player weight (decreasing to increasing)
import pandas
nbaDataFrame = pd.read_csv("NBA_CSV_DATA.csv")
sortedDataFrame = nbaDataFrame.sort_values('Weight',
ascending=True)
print sortedDataFrame[['Weight', 'Name']]
Pandas- Methods
• Creating a dataframe from scratch
Note: This is useful when you want to create a
dataframe and add data to it later
Pandas- Methods
• Add values to a dataframe after creating it
Adding Elements to CSV File
• Create new data and append (add) to current CSV File
• Data is added to the end (tail) of the DataFrame
• We can use lists!
• If no value is given for a column, it is empty
Adding Elements to CSV File
• Creating a new DataFrame, without reading a new CSV File
dataFrame = pd.DataFrame([[Data]], columns=[Columns])
• Data and Columns are just lists!
Constructing our new Data Frame
• We want to add a new player (new data) to our NBA CSV file
(existing data)
Ex:
new_player_columns = ['Name', 'Team', 'Number', 'Position', 'Age',
'Height', 'Weight', 'College', 'Salary']
new_player_data = ['Ray Allen', 'Boston Celtics', 10, "C", 24, "6-
6", 190, "Boston College", 800000]
Adding Elements to CSV File - String Concept
firstName = "Ray"
lastName = "Allen"
fullName = firstName + " " + lastName
print(fullName)
#Output:
# Ray Allen
• We can now think about this in terms of DataFrames!
Creating our new Data Frame
• Now we can make our new DataFrame using the data we made
newPlayerDataFrame = pd.DataFrame([new_player_data], columns= new_player_columns)
Combining DataFrames Together
• concat(parameters) - Takes a list of DataFrames and combines them,
we can pass in various parameters
combinedDataFrame = pd.concat([nbaDataFrame, new_player_dataframe])
print(combinedDataFrame.tail())
*Note - We print the tail as data is added to the end.
Pandas- Exercise
• Create an empty dataframe with the following columns
• [`num_1`, `num_2`, `num_3`]
• Generate random numbers and add 10 rows to the dataframe
Statistics of columns/features
Statistics of columns/features – how does it
help?
• Describes the range of different features
• Understand the range of feature the machine learning algorithm trained
with
• Variation within features
• Standard deviation indicates the variation of data within the range
Statistics of columns/features - visualize
Statistics of columns/features
Kaggle datasets
• Mobile price prediction
• Fish Weight Prediction
• Heights and Weights
• Student performance prediction
• Predict Airline Passenger Satisfaction
http://aiclub.world

More Related Content

What's hot

Pandas
PandasPandas
Pandas
Jyoti shukla
 
Hive and HiveQL - Module6
Hive and HiveQL - Module6Hive and HiveQL - Module6
Hive and HiveQL - Module6
Rohit Agrawal
 
Performing Data Science with HBase
Performing Data Science with HBasePerforming Data Science with HBase
Performing Data Science with HBase
WibiData
 
Pandas pythonfordatascience
Pandas pythonfordatasciencePandas pythonfordatascience
Pandas pythonfordatascience
Nishant Upadhyay
 
Exploratory data analysis using r
Exploratory data analysis using rExploratory data analysis using r
Exploratory data analysis using r
Tahera Shaikh
 
pandas - Python Data Analysis
pandas - Python Data Analysispandas - Python Data Analysis
pandas - Python Data Analysis
Andrew Henshaw
 
03 hive query language (hql)
03 hive query language (hql)03 hive query language (hql)
03 hive query language (hql)
Subhas Kumar Ghosh
 
managing big data
managing big datamanaging big data
managing big data
Suveeksha
 
R programming & Machine Learning
R programming & Machine LearningR programming & Machine Learning
R programming & Machine Learning
AmanBhalla14
 
Hive(ppt)
Hive(ppt)Hive(ppt)
Hive(ppt)
Abhinav Tyagi
 
Think Like Spark
Think Like SparkThink Like Spark
Think Like Spark
Alpine Data
 
R programming by ganesh kavhar
R programming by ganesh kavharR programming by ganesh kavhar
R programming by ganesh kavhar
Savitribai Phule Pune University
 
Introduction to pandas
Introduction to pandasIntroduction to pandas
Introduction to pandas
Piyush rai
 
Introduction to Pandas and Time Series Analysis [PyCon DE]
Introduction to Pandas and Time Series Analysis [PyCon DE]Introduction to Pandas and Time Series Analysis [PyCon DE]
Introduction to Pandas and Time Series Analysis [PyCon DE]
Alexander Hendorf
 

What's hot (14)

Pandas
PandasPandas
Pandas
 
Hive and HiveQL - Module6
Hive and HiveQL - Module6Hive and HiveQL - Module6
Hive and HiveQL - Module6
 
Performing Data Science with HBase
Performing Data Science with HBasePerforming Data Science with HBase
Performing Data Science with HBase
 
Pandas pythonfordatascience
Pandas pythonfordatasciencePandas pythonfordatascience
Pandas pythonfordatascience
 
Exploratory data analysis using r
Exploratory data analysis using rExploratory data analysis using r
Exploratory data analysis using r
 
pandas - Python Data Analysis
pandas - Python Data Analysispandas - Python Data Analysis
pandas - Python Data Analysis
 
03 hive query language (hql)
03 hive query language (hql)03 hive query language (hql)
03 hive query language (hql)
 
managing big data
managing big datamanaging big data
managing big data
 
R programming & Machine Learning
R programming & Machine LearningR programming & Machine Learning
R programming & Machine Learning
 
Hive(ppt)
Hive(ppt)Hive(ppt)
Hive(ppt)
 
Think Like Spark
Think Like SparkThink Like Spark
Think Like Spark
 
R programming by ganesh kavhar
R programming by ganesh kavharR programming by ganesh kavhar
R programming by ganesh kavhar
 
Introduction to pandas
Introduction to pandasIntroduction to pandas
Introduction to pandas
 
Introduction to Pandas and Time Series Analysis [PyCon DE]
Introduction to Pandas and Time Series Analysis [PyCon DE]Introduction to Pandas and Time Series Analysis [PyCon DE]
Introduction to Pandas and Time Series Analysis [PyCon DE]
 

Similar to Pa2 session 2

Quick dive to pandas
Quick dive to pandasQuick dive to pandas
Quick dive to pandas
Robin Kiplangat
 
Pandas Dataframe reading data Kirti final.pptx
Pandas Dataframe reading data  Kirti final.pptxPandas Dataframe reading data  Kirti final.pptx
Pandas Dataframe reading data Kirti final.pptx
Kirti Verma
 
Aia session1
Aia session1Aia session1
Aia session1
aiclub_slides
 
interenship.pptx
interenship.pptxinterenship.pptx
interenship.pptx
Naveen316549
 
pandas for series and dataframe.pptx
pandas for series and dataframe.pptxpandas for series and dataframe.pptx
pandas for series and dataframe.pptx
ssuser52a19e
 
Python-for-Data-Analysis.pptx
Python-for-Data-Analysis.pptxPython-for-Data-Analysis.pptx
Python-for-Data-Analysis.pptx
ParveenShaik21
 
DATA-Analysis-All-Slidescoursera.pdf
DATA-Analysis-All-Slidescoursera.pdfDATA-Analysis-All-Slidescoursera.pdf
DATA-Analysis-All-Slidescoursera.pdf
NamanKabadi1
 
B-6vdzrQSgaur3c60LoG1g_d0201f1ecaa148ca9ce77f6e15a62643_Data-Analysis-All-Sli...
B-6vdzrQSgaur3c60LoG1g_d0201f1ecaa148ca9ce77f6e15a62643_Data-Analysis-All-Sli...B-6vdzrQSgaur3c60LoG1g_d0201f1ecaa148ca9ce77f6e15a62643_Data-Analysis-All-Sli...
B-6vdzrQSgaur3c60LoG1g_d0201f1ecaa148ca9ce77f6e15a62643_Data-Analysis-All-Sli...
poojagupta010
 
Lecture 9.pptx
Lecture 9.pptxLecture 9.pptx
Lecture 9.pptx
MathewJohnSinoCruz
 
Pandas.pptx
Pandas.pptxPandas.pptx
Data Migration with Spark to Hive
Data Migration with Spark to HiveData Migration with Spark to Hive
Data Migration with Spark to Hive
Databricks
 
Unit 3_Numpy_Vsp.pptx
Unit 3_Numpy_Vsp.pptxUnit 3_Numpy_Vsp.pptx
Unit 3_Numpy_Vsp.pptx
prakashvs7
 
pandas directories on the python language.pptx
pandas directories on the python language.pptxpandas directories on the python language.pptx
pandas directories on the python language.pptx
SumitMajukar
 
Python Programming.pptx
Python Programming.pptxPython Programming.pptx
Python Programming.pptx
SudhakarVenkey
 
2 pandasbasic
2 pandasbasic2 pandasbasic
2 pandasbasic
pramod naik
 
Python for data analysis
Python for data analysisPython for data analysis
Python for data analysis
Savitribai Phule Pune University
 
Python Pandas for Data Science cheatsheet
Python Pandas for Data Science cheatsheet Python Pandas for Data Science cheatsheet
Python Pandas for Data Science cheatsheet
Dr. Volkan OBAN
 
Sas short course_presentation_11-4-09
Sas short course_presentation_11-4-09Sas short course_presentation_11-4-09
Sas short course_presentation_11-4-09
Prashant Ph
 
Sas short course_presentation_11-4-09
Sas short course_presentation_11-4-09Sas short course_presentation_11-4-09
Sas short course_presentation_11-4-09
Prashant Ph
 
Meetup Junio Data Analysis with python 2018
Meetup Junio Data Analysis with python 2018Meetup Junio Data Analysis with python 2018
Meetup Junio Data Analysis with python 2018
DataLab Community
 

Similar to Pa2 session 2 (20)

Quick dive to pandas
Quick dive to pandasQuick dive to pandas
Quick dive to pandas
 
Pandas Dataframe reading data Kirti final.pptx
Pandas Dataframe reading data  Kirti final.pptxPandas Dataframe reading data  Kirti final.pptx
Pandas Dataframe reading data Kirti final.pptx
 
Aia session1
Aia session1Aia session1
Aia session1
 
interenship.pptx
interenship.pptxinterenship.pptx
interenship.pptx
 
pandas for series and dataframe.pptx
pandas for series and dataframe.pptxpandas for series and dataframe.pptx
pandas for series and dataframe.pptx
 
Python-for-Data-Analysis.pptx
Python-for-Data-Analysis.pptxPython-for-Data-Analysis.pptx
Python-for-Data-Analysis.pptx
 
DATA-Analysis-All-Slidescoursera.pdf
DATA-Analysis-All-Slidescoursera.pdfDATA-Analysis-All-Slidescoursera.pdf
DATA-Analysis-All-Slidescoursera.pdf
 
B-6vdzrQSgaur3c60LoG1g_d0201f1ecaa148ca9ce77f6e15a62643_Data-Analysis-All-Sli...
B-6vdzrQSgaur3c60LoG1g_d0201f1ecaa148ca9ce77f6e15a62643_Data-Analysis-All-Sli...B-6vdzrQSgaur3c60LoG1g_d0201f1ecaa148ca9ce77f6e15a62643_Data-Analysis-All-Sli...
B-6vdzrQSgaur3c60LoG1g_d0201f1ecaa148ca9ce77f6e15a62643_Data-Analysis-All-Sli...
 
Lecture 9.pptx
Lecture 9.pptxLecture 9.pptx
Lecture 9.pptx
 
Pandas.pptx
Pandas.pptxPandas.pptx
Pandas.pptx
 
Data Migration with Spark to Hive
Data Migration with Spark to HiveData Migration with Spark to Hive
Data Migration with Spark to Hive
 
Unit 3_Numpy_Vsp.pptx
Unit 3_Numpy_Vsp.pptxUnit 3_Numpy_Vsp.pptx
Unit 3_Numpy_Vsp.pptx
 
pandas directories on the python language.pptx
pandas directories on the python language.pptxpandas directories on the python language.pptx
pandas directories on the python language.pptx
 
Python Programming.pptx
Python Programming.pptxPython Programming.pptx
Python Programming.pptx
 
2 pandasbasic
2 pandasbasic2 pandasbasic
2 pandasbasic
 
Python for data analysis
Python for data analysisPython for data analysis
Python for data analysis
 
Python Pandas for Data Science cheatsheet
Python Pandas for Data Science cheatsheet Python Pandas for Data Science cheatsheet
Python Pandas for Data Science cheatsheet
 
Sas short course_presentation_11-4-09
Sas short course_presentation_11-4-09Sas short course_presentation_11-4-09
Sas short course_presentation_11-4-09
 
Sas short course_presentation_11-4-09
Sas short course_presentation_11-4-09Sas short course_presentation_11-4-09
Sas short course_presentation_11-4-09
 
Meetup Junio Data Analysis with python 2018
Meetup Junio Data Analysis with python 2018Meetup Junio Data Analysis with python 2018
Meetup Junio Data Analysis with python 2018
 

More from aiclub_slides

Linear regression middleschool
Linear regression middleschoolLinear regression middleschool
Linear regression middleschool
aiclub_slides
 
Pa2 project template
Pa2 project templatePa2 project template
Pa2 project template
aiclub_slides
 
Knn intro advanced_middleschool
Knn intro advanced_middleschoolKnn intro advanced_middleschool
Knn intro advanced_middleschool
aiclub_slides
 
M1 regression metrics_middleschool
M1 regression metrics_middleschoolM1 regression metrics_middleschool
M1 regression metrics_middleschool
aiclub_slides
 
Pa1 json requests
Pa1 json requestsPa1 json requests
Pa1 json requests
aiclub_slides
 
Mnist images
Mnist imagesMnist images
Mnist images
aiclub_slides
 
Mnist images
Mnist imagesMnist images
Mnist images
aiclub_slides
 
Ai in real life face detection
Ai in real life   face detectionAi in real life   face detection
Ai in real life face detection
aiclub_slides
 
Cnn
CnnCnn
Res net high level intro
Res net high level introRes net high level intro
Res net high level intro
aiclub_slides
 
Neural networks and flattened images
Neural networks and flattened imagesNeural networks and flattened images
Neural networks and flattened images
aiclub_slides
 
What is a_neural_network
What is a_neural_networkWhat is a_neural_network
What is a_neural_network
aiclub_slides
 
How neural networks learn part iii
How neural networks learn part iiiHow neural networks learn part iii
How neural networks learn part iii
aiclub_slides
 
Introduction to deep learning image classification
Introduction to deep learning   image classificationIntroduction to deep learning   image classification
Introduction to deep learning image classification
aiclub_slides
 
Accuracy middleschool
Accuracy middleschoolAccuracy middleschool
Accuracy middleschool
aiclub_slides
 
Introduction to classification_middleschool
Introduction to classification_middleschoolIntroduction to classification_middleschool
Introduction to classification_middleschool
aiclub_slides
 
Introduction to the cloud
Introduction to the cloudIntroduction to the cloud
Introduction to the cloud
aiclub_slides
 
Basics of data
Basics of dataBasics of data
Basics of data
aiclub_slides
 
Ai basics
Ai basicsAi basics
Ai basics
aiclub_slides
 
Ai lifecycle and navigator
Ai lifecycle and navigatorAi lifecycle and navigator
Ai lifecycle and navigator
aiclub_slides
 

More from aiclub_slides (20)

Linear regression middleschool
Linear regression middleschoolLinear regression middleschool
Linear regression middleschool
 
Pa2 project template
Pa2 project templatePa2 project template
Pa2 project template
 
Knn intro advanced_middleschool
Knn intro advanced_middleschoolKnn intro advanced_middleschool
Knn intro advanced_middleschool
 
M1 regression metrics_middleschool
M1 regression metrics_middleschoolM1 regression metrics_middleschool
M1 regression metrics_middleschool
 
Pa1 json requests
Pa1 json requestsPa1 json requests
Pa1 json requests
 
Mnist images
Mnist imagesMnist images
Mnist images
 
Mnist images
Mnist imagesMnist images
Mnist images
 
Ai in real life face detection
Ai in real life   face detectionAi in real life   face detection
Ai in real life face detection
 
Cnn
CnnCnn
Cnn
 
Res net high level intro
Res net high level introRes net high level intro
Res net high level intro
 
Neural networks and flattened images
Neural networks and flattened imagesNeural networks and flattened images
Neural networks and flattened images
 
What is a_neural_network
What is a_neural_networkWhat is a_neural_network
What is a_neural_network
 
How neural networks learn part iii
How neural networks learn part iiiHow neural networks learn part iii
How neural networks learn part iii
 
Introduction to deep learning image classification
Introduction to deep learning   image classificationIntroduction to deep learning   image classification
Introduction to deep learning image classification
 
Accuracy middleschool
Accuracy middleschoolAccuracy middleschool
Accuracy middleschool
 
Introduction to classification_middleschool
Introduction to classification_middleschoolIntroduction to classification_middleschool
Introduction to classification_middleschool
 
Introduction to the cloud
Introduction to the cloudIntroduction to the cloud
Introduction to the cloud
 
Basics of data
Basics of dataBasics of data
Basics of data
 
Ai basics
Ai basicsAi basics
Ai basics
 
Ai lifecycle and navigator
Ai lifecycle and navigatorAi lifecycle and navigator
Ai lifecycle and navigator
 

Recently uploaded

C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Denish Jangid
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
HajraNaeem15
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
UGC NET Exam Paper 1- Unit 1:Teaching Aptitude
UGC NET Exam Paper 1- Unit 1:Teaching AptitudeUGC NET Exam Paper 1- Unit 1:Teaching Aptitude
UGC NET Exam Paper 1- Unit 1:Teaching Aptitude
S. Raj Kumar
 
How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience
Wahiba Chair Training & Consulting
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxBeyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
EduSkills OECD
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
Celine George
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
RAHUL
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skillsspot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
haiqairshad
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
Nguyen Thanh Tu Collection
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
Katrina Pritchard
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
GeorgeMilliken2
 

Recently uploaded (20)

C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
UGC NET Exam Paper 1- Unit 1:Teaching Aptitude
UGC NET Exam Paper 1- Unit 1:Teaching AptitudeUGC NET Exam Paper 1- Unit 1:Teaching Aptitude
UGC NET Exam Paper 1- Unit 1:Teaching Aptitude
 
How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxBeyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skillsspot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
 

Pa2 session 2

  • 1. Python with AI – 2 Session 2
  • 2. Pandas - Dataframe • Pandas is useful and important for reading CSV files, the datasets used for training models
  • 3. Pandas - Dataframe • Pandas is useful and important for reading CSV files, the datasets used for training models
  • 4. Pandas - Dataframe • Pandas is useful and important for reading CSV files, the datasets used for training models
  • 5. Pandas - Dataframe • Concept of index in a dataframe Index
  • 6. Pandas - Dataframe • Types of columns in dataframes
  • 7. Pandas - Dataframe • Access elements of a dataframe
  • 8. Interpreting CSV Data - Properties • len() - Returns the total amount of rows • shape - Returns an object which contains the total number of rows and columns • head(n) - Retrieves the top n (Integer) rows • info() - Displays all columns and their data types • dtypes() - Retrieves the column title and its respective data type • columns – Retrieves the column names
  • 9. Sorting CSV Files - Methods • Multiple different methods to sort columns and values • sort_values() - sorting the DataFrame by one or more columns • sort_index() - sorting the DataFrame by the row index import pandas nbaDataFrame = pd.read_csv("NBA_CSV_DATA.csv") nbaDataFrame.sort_values(parameters) nbaDataFrame.sort_index(parameters)
  • 10. Exploring CSV File Data - Value • Sorting columns by given player weight (decreasing to increasing) import pandas nbaDataFrame = pd.read_csv("NBA_CSV_DATA.csv") sortedDataFrame = nbaDataFrame.sort_values('Weight', ascending=True) print sortedDataFrame[['Weight', 'Name']]
  • 11. Exploring CSV File Data Output Note* : Values are sorted by row index when values are equal for given sorting factor.
  • 12. Pandas- Methods • Creating a dataframe from scratch
  • 13. Sorting CSV Files - Methods • Multiple different methods to sort columns and values • sort_values() - sorting the DataFrame by one or more columns • sort_index() - sorting the DataFrame by the row index import pandas nbaDataFrame = pd.read_csv("NBA_CSV_DATA.csv") nbaDataFrame.sort_values(parameters) nbaDataFrame.sort_index(parameters)
  • 14. Exploring CSV File Data Output Note* : Values are sorted by row index when values are equal for given sorting factor.
  • 15. Exploring CSV File Data - Value • Sorting columns by given player weight (decreasing to increasing) import pandas nbaDataFrame = pd.read_csv("NBA_CSV_DATA.csv") sortedDataFrame = nbaDataFrame.sort_values('Weight', ascending=True) print sortedDataFrame[['Weight', 'Name']]
  • 16. Pandas- Methods • Creating a dataframe from scratch Note: This is useful when you want to create a dataframe and add data to it later
  • 17. Pandas- Methods • Add values to a dataframe after creating it
  • 18. Adding Elements to CSV File • Create new data and append (add) to current CSV File • Data is added to the end (tail) of the DataFrame • We can use lists! • If no value is given for a column, it is empty
  • 19. Adding Elements to CSV File • Creating a new DataFrame, without reading a new CSV File dataFrame = pd.DataFrame([[Data]], columns=[Columns]) • Data and Columns are just lists!
  • 20. Constructing our new Data Frame • We want to add a new player (new data) to our NBA CSV file (existing data) Ex: new_player_columns = ['Name', 'Team', 'Number', 'Position', 'Age', 'Height', 'Weight', 'College', 'Salary'] new_player_data = ['Ray Allen', 'Boston Celtics', 10, "C", 24, "6- 6", 190, "Boston College", 800000]
  • 21. Adding Elements to CSV File - String Concept firstName = "Ray" lastName = "Allen" fullName = firstName + " " + lastName print(fullName) #Output: # Ray Allen • We can now think about this in terms of DataFrames!
  • 22. Creating our new Data Frame • Now we can make our new DataFrame using the data we made newPlayerDataFrame = pd.DataFrame([new_player_data], columns= new_player_columns)
  • 23. Combining DataFrames Together • concat(parameters) - Takes a list of DataFrames and combines them, we can pass in various parameters combinedDataFrame = pd.concat([nbaDataFrame, new_player_dataframe]) print(combinedDataFrame.tail()) *Note - We print the tail as data is added to the end.
  • 24. Pandas- Exercise • Create an empty dataframe with the following columns • [`num_1`, `num_2`, `num_3`] • Generate random numbers and add 10 rows to the dataframe
  • 26. Statistics of columns/features – how does it help? • Describes the range of different features • Understand the range of feature the machine learning algorithm trained with • Variation within features • Standard deviation indicates the variation of data within the range
  • 29. Kaggle datasets • Mobile price prediction • Fish Weight Prediction • Heights and Weights • Student performance prediction • Predict Airline Passenger Satisfaction