SlideShare a Scribd company logo
1 of 37
AIA – Session1
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.
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?
Modules in python
• Use multiple functions written by others
Modules in python
• Use multiple functions written by others
• Popular packages: numpy, pandas, random
• How do you import modules
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.
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
• 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
http://aiclub.world

More Related Content

Similar to Aia session1

Educational Objectives After successfully completing this assignmen.pdf
Educational Objectives After successfully completing this assignmen.pdfEducational Objectives After successfully completing this assignmen.pdf
Educational Objectives After successfully completing this assignmen.pdf
rajeshjangid1865
 
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
 

Similar to Aia session1 (20)

Python for data analysis
Python for data analysisPython for data analysis
Python for data analysis
 
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
 
Lecture 9.pptx
Lecture 9.pptxLecture 9.pptx
Lecture 9.pptx
 
Python-for-Data-Analysis.pptx
Python-for-Data-Analysis.pptxPython-for-Data-Analysis.pptx
Python-for-Data-Analysis.pptx
 
Python for Data Analysis.pdf
Python for Data Analysis.pdfPython for Data Analysis.pdf
Python for Data Analysis.pdf
 
Python-for-Data-Analysis.pptx
Python-for-Data-Analysis.pptxPython-for-Data-Analysis.pptx
Python-for-Data-Analysis.pptx
 
Python-for-Data-Analysis.pdf
Python-for-Data-Analysis.pdfPython-for-Data-Analysis.pdf
Python-for-Data-Analysis.pdf
 
Python-for-Data-Analysis.pptx
Python-for-Data-Analysis.pptxPython-for-Data-Analysis.pptx
Python-for-Data-Analysis.pptx
 
More on Pandas.pptx
More on Pandas.pptxMore on Pandas.pptx
More on Pandas.pptx
 
Pa1 session 2
Pa1 session 2 Pa1 session 2
Pa1 session 2
 
Pa2 session 2
Pa2 session 2Pa2 session 2
Pa2 session 2
 
Educational Objectives After successfully completing this assignmen.pdf
Educational Objectives After successfully completing this assignmen.pdfEducational Objectives After successfully completing this assignmen.pdf
Educational Objectives After successfully completing this assignmen.pdf
 
PPT on Data Science Using Python
PPT on Data Science Using PythonPPT on Data Science Using Python
PPT on Data Science Using Python
 
Unit 3_Numpy_Vsp.pptx
Unit 3_Numpy_Vsp.pptxUnit 3_Numpy_Vsp.pptx
Unit 3_Numpy_Vsp.pptx
 
INTRODUCTION TO C PROGRAMMING in basic c language
INTRODUCTION TO C PROGRAMMING in basic c languageINTRODUCTION TO C PROGRAMMING in basic c language
INTRODUCTION TO C PROGRAMMING in basic c language
 
interenship.pptx
interenship.pptxinterenship.pptx
interenship.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 basics
Python basicsPython basics
Python basics
 
Python basics
Python basicsPython basics
Python basics
 
Python basics
Python basicsPython basics
Python basics
 

More from 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

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
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
negromaestrong
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 

Recently uploaded (20)

Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
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
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).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...
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 

Aia session1

  • 2. Where will we build an App? • An online tool: repl • Link: https://repl.it/~ • Create a personal account
  • 3. Launch a python program Click on the blue button on top right corner that says + new repl
  • 4. Create the first program Click here
  • 5. Ask for user input
  • 6. 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
  • 7. Conditionals • The if statement Conditional Description == Equal != Not Equal > Greater than < Less than >= Greater than or equal to <= Less than or equal to
  • 8. 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.
  • 9. Lists in python • A list holds ordered collection of items. • And item can be a string or a number
  • 10. Dictionaries - Recap • A dictionary consists of two things (a) keys (b) values • Use strings to represent keys • Values can be anything
  • 11. 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
  • 12. Functions can accept and return multiple values • How would you call this function?
  • 13. Modules in python • Use multiple functions written by others
  • 14. Modules in python • Use multiple functions written by others • Popular packages: numpy, pandas, random • How do you import modules
  • 15. Create random numbers • Generate random integers • Generate random numbers
  • 16. 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.
  • 17. Pandas - Dataframe • Pandas is useful and important for reading CSV files, the datasets used for training models
  • 18. Pandas - Dataframe • Pandas is useful and important for reading CSV files, the datasets used for training models
  • 19. Pandas - Dataframe • Pandas is useful and important for reading CSV files, the datasets used for training models
  • 20. Pandas - Dataframe • Concept of index in a dataframe Index
  • 21. Pandas - Dataframe • Types of columns in dataframes
  • 22. Pandas - Dataframe • Access elements of a dataframe
  • 23. 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
  • 24. Pandas- Methods • Creating a dataframe from scratch Note: This is useful when you want to create a dataframe and add data to it later
  • 25. Pandas- Methods • Add values to a dataframe after creating it
  • 26. 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
  • 27. 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!
  • 28. 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]
  • 29. 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!
  • 30. 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)
  • 31. 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.
  • 32. 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
  • 34. 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