SlideShare ist ein Scribd-Unternehmen logo
1 von 42
Python with AI – 2
Session 1
Logistics
• All exercises are shown in repl
• Please paste your repl link for this session in the google sheet
• Be prepared to share your screen
• A repl link with questions to all exercises we will do today in the
class will be provided
Course Curriculum
Session Number What is covered
1 Python basics – recap
2 pandas Dataframes and Kaggle dataset
3 Dataset Manipulation - 1
4 REST API and Github
5 Visualization of AI Metrics
6 Visualization of data - 1
7 Visualization of data - 2
8 Final Projects
Where will we build
an App?
• An online tool: repl
• Link: https://repl.it/~
• Create a personal account
Launch a python program
Click on the blue button on top right corner that says + new repl
Create the first program
Click here
Ask for user input
Operators in python
Operator Syntax Description
Sum + Adds two numbers (or) strings
Subtraction - Only numbers
Product * Product of numbers, repetition of strings
Division / Division between numbers
Modulo % Remainder of division between two
numbers
Power ** Power of one number over another
Conditionals
• The if statement
Conditional Description
== Equal
!= Not Equal
> Greater than
< Less than
>= Greater than or equal to
<= Less than or equal to
Loops
• The for loop is of the following form.
• The range indicates the number of times a statement will be implemented.
• There is a colon value to indicate the start of for loop.
• The code below is executed many times. The number of times it gets executed
depends on the values specified in range.
• Note that the code below the for statement is indented.
Write to a file
• Open a new file if it does not exist
• Write to the file
• Close the file
Append to a file
• Open a new file if it does not exist
• Write to the file
• Close the file
Lists in python
• A list holds ordered collection of items.
• And item can be a string or a number
Dictionaries - Recap
• A dictionary consists of two things (a) keys (b) values
• Use strings to represent keys
• Values can be anything
Dictionaries - Recap
• Print a value in a dictionary
• Delete a value in a dictionary
• Print all keys of a dictionary
• Add values to a dictionary
Functions can accept and return multiple
values
• How would you call this function?
Measuring Run Time of Code
import time
start_time = time.time()
//
print(“Hello”)
//
seconds = time.time() - start_time
print('Time Taken:', time.strftime("%H:%M:%S", time.gmtime(seconds)))
# Output: Time Taken: 00:00:08
● Main() is the function that contains the code to be executed
● We use the time library to ease with measuring run time, various
time zones, and more
Modules in python
• Use multiple functions written by others
Modules in python
• Use multiple functions written by others
• Popular packages: numpy, pandas
• How do you tell python to use these packages?
Modules in python
• Use multiple functions written by others
• Popular packages: numpy, pandas
• How do you tell python to use these packages?
Numpy package - arrays
• Example of an array
Numpy package - arrays
• Example of a 2D array
Can all lists be converted to numpy arrays?
Why should I use a numpy array?
• Arrays are more convenient – How?
Create random numbers
Create random numbers
• Generate random integers
• Generate random numbers
Exercise
Programming exercise 1:
a) Ask the user to input an integer N. Create a list with the length N, containing
random numbers between 0 and N*2. Make sure that there are no duplicates
in the list created.
b) Create dictionary N keys, where the keys are the values in the list generated
in the previous step. Values are random numbers between 0 and 10.
c) Create a list that contains the values of the dictionary created in the previous
step as its entries.
Modules in python
• Use multiple functions written by others
Modules in python
• Use multiple functions written by others
• Popular packages: numpy, pandas
• How do you tell python to use these packages?
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
Pandas- Methods
• Dropping columns from a dataframe
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 - 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.
http://aiclub.world

Weitere ähnliche Inhalte

Was ist angesagt?

The Scheme Language -- Using it on the iPhone
The Scheme Language -- Using it on the iPhoneThe Scheme Language -- Using it on the iPhone
The Scheme Language -- Using it on the iPhoneJames Long
 
Hash tables and hash maps in python | Edureka
Hash tables and hash maps in python | EdurekaHash tables and hash maps in python | Edureka
Hash tables and hash maps in python | EdurekaEdureka!
 
Introduction to Programming in LISP
Introduction to Programming in LISPIntroduction to Programming in LISP
Introduction to Programming in LISPKnoldus Inc.
 
Jake Mannix, Lead Data Engineer, Lucidworks at MLconf SEA - 5/20/16
Jake Mannix, Lead Data Engineer, Lucidworks at MLconf SEA - 5/20/16Jake Mannix, Lead Data Engineer, Lucidworks at MLconf SEA - 5/20/16
Jake Mannix, Lead Data Engineer, Lucidworks at MLconf SEA - 5/20/16MLconf
 
Mathias Brandewinder, Software Engineer & Data Scientist, Clear Lines Consult...
Mathias Brandewinder, Software Engineer & Data Scientist, Clear Lines Consult...Mathias Brandewinder, Software Engineer & Data Scientist, Clear Lines Consult...
Mathias Brandewinder, Software Engineer & Data Scientist, Clear Lines Consult...MLconf
 
Dictionary based Annotation at Scale with Spark, SolrTextTagger and OpenNLP
Dictionary based Annotation at Scale with Spark, SolrTextTagger and OpenNLPDictionary based Annotation at Scale with Spark, SolrTextTagger and OpenNLP
Dictionary based Annotation at Scale with Spark, SolrTextTagger and OpenNLPSujit Pal
 
Functional Programming #FTW
Functional Programming #FTWFunctional Programming #FTW
Functional Programming #FTWAdriano Bonat
 
Coding and Cookies: R basics
Coding and Cookies: R basicsCoding and Cookies: R basics
Coding and Cookies: R basicsC. Tobin Magle
 
Scheme Programming Language
Scheme Programming LanguageScheme Programming Language
Scheme Programming LanguageReham AlBlehid
 
INTRODUCTION TO LISP
INTRODUCTION TO LISPINTRODUCTION TO LISP
INTRODUCTION TO LISPNilt1234
 
Basic data analysis using R.
Basic data analysis using R.Basic data analysis using R.
Basic data analysis using R.C. Tobin Magle
 
Pytorch Ecosystem Day: The 珞 Ecosystem
Pytorch Ecosystem Day: The 珞 EcosystemPytorch Ecosystem Day: The 珞 Ecosystem
Pytorch Ecosystem Day: The 珞 EcosystemLysandre Debut
 
Python programming
Python programmingPython programming
Python programmingsirikeshava
 
(Kpi summer school 2015) theano tutorial part1
(Kpi summer school 2015) theano tutorial part1(Kpi summer school 2015) theano tutorial part1
(Kpi summer school 2015) theano tutorial part1Serhii Havrylov
 

Was ist angesagt? (19)

Python with data Sciences
Python with data SciencesPython with data Sciences
Python with data Sciences
 
The Scheme Language -- Using it on the iPhone
The Scheme Language -- Using it on the iPhoneThe Scheme Language -- Using it on the iPhone
The Scheme Language -- Using it on the iPhone
 
Hash tables and hash maps in python | Edureka
Hash tables and hash maps in python | EdurekaHash tables and hash maps in python | Edureka
Hash tables and hash maps in python | Edureka
 
Introduction to Programming in LISP
Introduction to Programming in LISPIntroduction to Programming in LISP
Introduction to Programming in LISP
 
Jake Mannix, Lead Data Engineer, Lucidworks at MLconf SEA - 5/20/16
Jake Mannix, Lead Data Engineer, Lucidworks at MLconf SEA - 5/20/16Jake Mannix, Lead Data Engineer, Lucidworks at MLconf SEA - 5/20/16
Jake Mannix, Lead Data Engineer, Lucidworks at MLconf SEA - 5/20/16
 
Mathias Brandewinder, Software Engineer & Data Scientist, Clear Lines Consult...
Mathias Brandewinder, Software Engineer & Data Scientist, Clear Lines Consult...Mathias Brandewinder, Software Engineer & Data Scientist, Clear Lines Consult...
Mathias Brandewinder, Software Engineer & Data Scientist, Clear Lines Consult...
 
Dictionary based Annotation at Scale with Spark, SolrTextTagger and OpenNLP
Dictionary based Annotation at Scale with Spark, SolrTextTagger and OpenNLPDictionary based Annotation at Scale with Spark, SolrTextTagger and OpenNLP
Dictionary based Annotation at Scale with Spark, SolrTextTagger and OpenNLP
 
Introduction to r
Introduction to rIntroduction to r
Introduction to r
 
Functional Programming #FTW
Functional Programming #FTWFunctional Programming #FTW
Functional Programming #FTW
 
Coding and Cookies: R basics
Coding and Cookies: R basicsCoding and Cookies: R basics
Coding and Cookies: R basics
 
Scheme language
Scheme languageScheme language
Scheme language
 
Basic lisp
Basic lispBasic lisp
Basic lisp
 
Lisp
LispLisp
Lisp
 
Scheme Programming Language
Scheme Programming LanguageScheme Programming Language
Scheme Programming Language
 
INTRODUCTION TO LISP
INTRODUCTION TO LISPINTRODUCTION TO LISP
INTRODUCTION TO LISP
 
Basic data analysis using R.
Basic data analysis using R.Basic data analysis using R.
Basic data analysis using R.
 
Pytorch Ecosystem Day: The 珞 Ecosystem
Pytorch Ecosystem Day: The 珞 EcosystemPytorch Ecosystem Day: The 珞 Ecosystem
Pytorch Ecosystem Day: The 珞 Ecosystem
 
Python programming
Python programmingPython programming
Python programming
 
(Kpi summer school 2015) theano tutorial part1
(Kpi summer school 2015) theano tutorial part1(Kpi summer school 2015) theano tutorial part1
(Kpi summer school 2015) theano tutorial part1
 

Ähnlich wie Pa2 session 1

Python Programming and GIS
Python Programming and GISPython Programming and GIS
Python Programming and GISJohn Reiser
 
Python first day
Python first dayPython first day
Python first dayfarkhand
 
web programming UNIT VIII python by Bhavsingh Maloth
web programming UNIT VIII python by Bhavsingh Malothweb programming UNIT VIII python by Bhavsingh Maloth
web programming UNIT VIII python by Bhavsingh MalothBhavsingh Maloth
 
Engineering CS 5th Sem Python Module -2.pptx
Engineering CS 5th Sem Python Module -2.pptxEngineering CS 5th Sem Python Module -2.pptx
Engineering CS 5th Sem Python Module -2.pptxhardii0991
 
Python introduction
Python introductionPython introduction
Python introductionRoger Xia
 
Lec16-CS110 Computational Engineering
Lec16-CS110 Computational EngineeringLec16-CS110 Computational Engineering
Lec16-CS110 Computational EngineeringSri Harsha Pamu
 
Module 3,4.pptx
Module 3,4.pptxModule 3,4.pptx
Module 3,4.pptxSandeepR95
 
Functions, List and String methods
Functions, List and String methodsFunctions, List and String methods
Functions, List and String methodsPranavSB
 
WiNGS 2014 Workshop 2 R, RStudio, and reproducible research with knitr
WiNGS 2014 Workshop 2 R, RStudio, and reproducible research with knitrWiNGS 2014 Workshop 2 R, RStudio, and reproducible research with knitr
WiNGS 2014 Workshop 2 R, RStudio, and reproducible research with knitrAnn Loraine
 
Automation Testing theory notes.pptx
Automation Testing theory notes.pptxAutomation Testing theory notes.pptx
Automation Testing theory notes.pptxNileshBorkar12
 
Travis Oliphant "Python for Speed, Scale, and Science"
Travis Oliphant "Python for Speed, Scale, and Science"Travis Oliphant "Python for Speed, Scale, and Science"
Travis Oliphant "Python for Speed, Scale, and Science"Fwdays
 

Ähnlich wie Pa2 session 1 (20)

Python
PythonPython
Python
 
Pa1 session 5
Pa1 session 5Pa1 session 5
Pa1 session 5
 
Python Tutorial Part 1
Python Tutorial Part 1Python Tutorial Part 1
Python Tutorial Part 1
 
Python Programming and GIS
Python Programming and GISPython Programming and GIS
Python Programming and GIS
 
Python first day
Python first dayPython first day
Python first day
 
Python first day
Python first dayPython first day
Python first day
 
web programming UNIT VIII python by Bhavsingh Maloth
web programming UNIT VIII python by Bhavsingh Malothweb programming UNIT VIII python by Bhavsingh Maloth
web programming UNIT VIII python by Bhavsingh Maloth
 
Introduction_to_Python.pptx
Introduction_to_Python.pptxIntroduction_to_Python.pptx
Introduction_to_Python.pptx
 
Engineering CS 5th Sem Python Module -2.pptx
Engineering CS 5th Sem Python Module -2.pptxEngineering CS 5th Sem Python Module -2.pptx
Engineering CS 5th Sem Python Module -2.pptx
 
Python-Basics.pptx
Python-Basics.pptxPython-Basics.pptx
Python-Basics.pptx
 
Python ppt
Python pptPython ppt
Python ppt
 
Python Demo.pptx
Python Demo.pptxPython Demo.pptx
Python Demo.pptx
 
Python Demo.pptx
Python Demo.pptxPython Demo.pptx
Python Demo.pptx
 
Python introduction
Python introductionPython introduction
Python introduction
 
Lec16-CS110 Computational Engineering
Lec16-CS110 Computational EngineeringLec16-CS110 Computational Engineering
Lec16-CS110 Computational Engineering
 
Module 3,4.pptx
Module 3,4.pptxModule 3,4.pptx
Module 3,4.pptx
 
Functions, List and String methods
Functions, List and String methodsFunctions, List and String methods
Functions, List and String methods
 
WiNGS 2014 Workshop 2 R, RStudio, and reproducible research with knitr
WiNGS 2014 Workshop 2 R, RStudio, and reproducible research with knitrWiNGS 2014 Workshop 2 R, RStudio, and reproducible research with knitr
WiNGS 2014 Workshop 2 R, RStudio, and reproducible research with knitr
 
Automation Testing theory notes.pptx
Automation Testing theory notes.pptxAutomation Testing theory notes.pptx
Automation Testing theory notes.pptx
 
Travis Oliphant "Python for Speed, Scale, and Science"
Travis Oliphant "Python for Speed, Scale, and Science"Travis Oliphant "Python for Speed, Scale, and Science"
Travis Oliphant "Python for Speed, Scale, and Science"
 

Mehr von aiclub_slides

Linear regression middleschool
Linear regression middleschoolLinear regression middleschool
Linear regression middleschoolaiclub_slides
 
Pa2 project template
Pa2 project templatePa2 project template
Pa2 project templateaiclub_slides
 
Knn intro advanced_middleschool
Knn intro advanced_middleschoolKnn intro advanced_middleschool
Knn intro advanced_middleschoolaiclub_slides
 
M1 regression metrics_middleschool
M1 regression metrics_middleschoolM1 regression metrics_middleschool
M1 regression metrics_middleschoolaiclub_slides
 
Ai in real life face detection
Ai in real life   face detectionAi in real life   face detection
Ai in real life face detectionaiclub_slides
 
Res net high level intro
Res net high level introRes net high level intro
Res net high level introaiclub_slides
 
Neural networks and flattened images
Neural networks and flattened imagesNeural networks and flattened images
Neural networks and flattened imagesaiclub_slides
 
What is a_neural_network
What is a_neural_networkWhat is a_neural_network
What is a_neural_networkaiclub_slides
 
How neural networks learn part iii
How neural networks learn part iiiHow neural networks learn part iii
How neural networks learn part iiiaiclub_slides
 
Introduction to deep learning image classification
Introduction to deep learning   image classificationIntroduction to deep learning   image classification
Introduction to deep learning image classificationaiclub_slides
 
Accuracy middleschool
Accuracy middleschoolAccuracy middleschool
Accuracy middleschoolaiclub_slides
 
Introduction to classification_middleschool
Introduction to classification_middleschoolIntroduction to classification_middleschool
Introduction to classification_middleschoolaiclub_slides
 
Introduction to the cloud
Introduction to the cloudIntroduction to the cloud
Introduction to the cloudaiclub_slides
 
Ai lifecycle and navigator
Ai lifecycle and navigatorAi lifecycle and navigator
Ai lifecycle and navigatoraiclub_slides
 

Mehr von 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
 

Kürzlich hochgeladen

Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 

Kürzlich hochgeladen (20)

Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 

Pa2 session 1

  • 1. Python with AI – 2 Session 1
  • 2. Logistics • All exercises are shown in repl • Please paste your repl link for this session in the google sheet • Be prepared to share your screen • A repl link with questions to all exercises we will do today in the class will be provided
  • 3. Course Curriculum Session Number What is covered 1 Python basics – recap 2 pandas Dataframes and Kaggle dataset 3 Dataset Manipulation - 1 4 REST API and Github 5 Visualization of AI Metrics 6 Visualization of data - 1 7 Visualization of data - 2 8 Final Projects
  • 4. Where will we build an App? • An online tool: repl • Link: https://repl.it/~ • Create a personal account
  • 5. Launch a python program Click on the blue button on top right corner that says + new repl
  • 6. Create the first program Click here
  • 7. Ask for user input
  • 8. Operators in python Operator Syntax Description Sum + Adds two numbers (or) strings Subtraction - Only numbers Product * Product of numbers, repetition of strings Division / Division between numbers Modulo % Remainder of division between two numbers Power ** Power of one number over another
  • 9. Conditionals • The if statement Conditional Description == Equal != Not Equal > Greater than < Less than >= Greater than or equal to <= Less than or equal to
  • 10. Loops • The for loop is of the following form. • The range indicates the number of times a statement will be implemented. • There is a colon value to indicate the start of for loop. • The code below is executed many times. The number of times it gets executed depends on the values specified in range. • Note that the code below the for statement is indented.
  • 11. Write to a file • Open a new file if it does not exist • Write to the file • Close the file
  • 12. Append to a file • Open a new file if it does not exist • Write to the file • Close the file
  • 13. Lists in python • A list holds ordered collection of items. • And item can be a string or a number
  • 14. Dictionaries - Recap • A dictionary consists of two things (a) keys (b) values • Use strings to represent keys • Values can be anything
  • 15. Dictionaries - Recap • Print a value in a dictionary • Delete a value in a dictionary • Print all keys of a dictionary • Add values to a dictionary
  • 16. Functions can accept and return multiple values • How would you call this function?
  • 17. Measuring Run Time of Code import time start_time = time.time() // print(“Hello”) // seconds = time.time() - start_time print('Time Taken:', time.strftime("%H:%M:%S", time.gmtime(seconds))) # Output: Time Taken: 00:00:08 ● Main() is the function that contains the code to be executed ● We use the time library to ease with measuring run time, various time zones, and more
  • 18. Modules in python • Use multiple functions written by others
  • 19. Modules in python • Use multiple functions written by others • Popular packages: numpy, pandas • How do you tell python to use these packages?
  • 20. Modules in python • Use multiple functions written by others • Popular packages: numpy, pandas • How do you tell python to use these packages?
  • 21. Numpy package - arrays • Example of an array
  • 22. Numpy package - arrays • Example of a 2D array
  • 23. Can all lists be converted to numpy arrays?
  • 24. Why should I use a numpy array? • Arrays are more convenient – How?
  • 26. Create random numbers • Generate random integers • Generate random numbers
  • 27. Exercise Programming exercise 1: a) Ask the user to input an integer N. Create a list with the length N, containing random numbers between 0 and N*2. Make sure that there are no duplicates in the list created. b) Create dictionary N keys, where the keys are the values in the list generated in the previous step. Values are random numbers between 0 and 10. c) Create a list that contains the values of the dictionary created in the previous step as its entries.
  • 28. Modules in python • Use multiple functions written by others
  • 29. Modules in python • Use multiple functions written by others • Popular packages: numpy, pandas • How do you tell python to use these packages?
  • 30. Pandas - Dataframe • Pandas is useful and important for reading CSV files, the datasets used for training models
  • 31. Pandas - Dataframe • Pandas is useful and important for reading CSV files, the datasets used for training models
  • 32. Pandas - Dataframe • Pandas is useful and important for reading CSV files, the datasets used for training models
  • 33. Pandas - Dataframe • Concept of index in a dataframe Index
  • 34. Pandas - Dataframe • Types of columns in dataframes
  • 35. Pandas - Dataframe • Access elements of a dataframe
  • 36. 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
  • 37. Pandas- Methods • Dropping columns from a dataframe
  • 38. Pandas- Methods • Creating a dataframe from scratch
  • 39. 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)
  • 40. 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']]
  • 41. Exploring CSV File Data Output Note* : Values are sorted by row index when values are equal for given sorting factor.