SlideShare a Scribd company logo
1 of 22
Download to read offline
The pandas Library
Haim Michael
September 8th
, 2020
All logos, trade marks and brand names used in this presentation belong
to the respective owners.
lifemichael
https://youtu.be/Go_6xXYEtkw
© 2008 Haim Michael 20150729
What is Pandas?
 Pandas is a fast, powerful, flexible and easy to use open
source data analysis and manipulation tool, built on top of
the Python programming language. (pandas.pydata.org)
© 2008 Haim Michael 20150729
Installing Pandas
 There are more than a few ways to install Pandas. The
simplest would be using the pip utility.
pip install pandas
© 2008 Haim Michael 20150729
Checking Pandas Version
 You can easily check the version of the Pandas library you
already have installed using the following code.
 The expected output should look like the following:
© 2008 Haim Michael 20150729
Importing Pandas
 In order to use Pandas we should first importing it. It is a
common practice to import it using the alias pd.
import pandas as pd
© 2008 Haim Michael 20150729
The DataFrame Class
 When instantiating the DataFrame class we will get an
object that represents a table.
import pandas as pd
df = pd.DataFrame({ "country":["israel","france","germany"],
"currency":["ils","euro","euro"],
"capitol":["jerusalem","paris","berlin"]
})
print(df)
© 2008 Haim Michael 20150729
The Series Class
 Each and every column of a DataFrame object is
represented using a Series object.
import pandas as pd
marks = pd.Series([88,90,72,64], name="Mark")
print(marks)
© 2008 Haim Michael 20150729
The describe() Function
 We can invoke this method both on a Series object and on a
DataFrame object. Calling this function we will get a detailed
statistic description.
import pandas as pd
marks = pd.Series([88,90,72,64], name="Mark")
print(marks.describe())
© 2008 Haim Michael 20150729
Reading & Writing Data
 The available methods allow us to read data from files in
various formats directly into a DataFrame object, and to
write data we already have in a DataFrame object directly to
files in various formats.
© 2008 Haim Michael 20150729
Reading & Writing Data
 The to_excel, to_csv, etc... are methods that we invoke
on a DataFrame object. These methods allow us to to write
the data we already have organized in a DataFrame object
to a new file of a specific format.
 The read_excel, read_csv, etc... are public methods that
were defined in the pandas module.
© 2008 Haim Michael 20150729
Writing to Excel Sample
import pandas as pd
df = pd.DataFrame({ "country":["israel","france","germany"],
"currency":["ils","euro","euro"],
"capitol":["jerusalem","paris","berlin"]
}
)
df.to_excel("countries.xlsx")
© 2008 Haim Michael 20150729
Reading from CSV
import pandas as pd
ob = pd.read_csv("countries.csv")
print(ob)
© 2008 Haim Michael 20150729
Selecting Column
 Selecting a column is done by using square brackets
together with the column name of the column of interest.
Each column is represented using an object of the type
Series.
© 2008 Haim Michael 20150729
Selecting Column
import pandas as pd
df = pd.DataFrame({ "country":["israel","france","germany"],
"currency":["ils","euro","euro"],
"capitol":["jerusalem","paris","berlin"]
}
)
countries = df["country"]
print(countries)
print(type(countries)
© 2008 Haim Michael 20150729
Selecting Columns
 Selecting multiple columns is done by using a list of column
names.
© 2008 Haim Michael 20150729
Selecting Columns
import pandas as pd
df = pd.DataFrame({ "country":["israel","france","germany"],
"currency":["ils","euro","euro"],
"capitol":["jerusalem","paris","berlin"]
}
)
ob = df[["country","capitol"]]
print(ob)
print(type(ob))
© 2008 Haim Michael 20150729
Selecting Rows
 Selecting rows based on a specific condition is done using a
condition we specify inside the selection brackets.
© 2008 Haim Michael 20150729
Selecting Rows
import pandas as pd
df = pd.DataFrame({ "first name":["moshe","daniel","tal"],
"last name":["israeli","cohen","lahat"],
"id":["234234","645645","678678"],
"average":[85,90,64]
}
)
beststudents = df[df["average"]>80]
print(beststudents)
print(type(beststudents))
© 2008 Haim Michael 20150729
Selecting Rows
 Selecting rows that a specific column in the selected row
has a value which is a specific value.
© 2008 Haim Michael 20150729
Selecting Rows
import pandas as pd
df = pd.DataFrame({ "first name":["moshe","daniel","tal","jane"],
"last name":["israeli","cohen","lahat","lala"],
"id":["234234","645645","678678","234234"],
"class":["1st","1st","2nd","3rd"]
}
)
premiumpassengers = df[(df["class"] == "1st") | (df["class"] == "3rd")]
print(premiumpassengers)
print(type(premiumpassengers))
© 2008 Haim Michael 20150729
Selecting Multiple Rows & Cols
 In order to select multiple rows and cols, a subset of our
data, we should use the iloc operator.
© 2008 Haim Michael 20150729
Selecting Multiple Rows & Cols
import pandas as pd
df = pd.DataFrame({ "first name":["moshe","daniel","tal"],
"last name":["israeli","cohen","lahat"],
"id":["234234","645645","678678"],
"class":["1st","1st","2nd"]
}
)
ob = df.iloc[0:2,0:2]
print(ob)
print(type(ob))

More Related Content

Similar to Pandas meetup 20200908

Import contents, taxonomies and translations in Drupal8
Import contents, taxonomies and translations in Drupal8Import contents, taxonomies and translations in Drupal8
Import contents, taxonomies and translations in Drupal8Takafumi Oinuma
 
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Amazon Web Services
 
Data Analysis with Python Pandas
Data Analysis with Python PandasData Analysis with Python Pandas
Data Analysis with Python PandasNeeru Mittal
 
"R & Text Analytics" (15 January 2013)
"R & Text Analytics" (15 January 2013)"R & Text Analytics" (15 January 2013)
"R & Text Analytics" (15 January 2013)Portland R User Group
 
Hivemall Talk at TD tech talk #3
Hivemall Talk at TD tech talk #3Hivemall Talk at TD tech talk #3
Hivemall Talk at TD tech talk #3Makoto Yui
 
Functional programming in Java
Functional programming in Java  Functional programming in Java
Functional programming in Java Haim Michael
 
A framework used to bridge between the language of business and PLCS
A framework used to bridge between the language of business and PLCSA framework used to bridge between the language of business and PLCS
A framework used to bridge between the language of business and PLCSMagnus Färneland
 
ML Best Practices: Prepare Data, Build Models, and Manage Lifecycle (AIM396-S...
ML Best Practices: Prepare Data, Build Models, and Manage Lifecycle (AIM396-S...ML Best Practices: Prepare Data, Build Models, and Manage Lifecycle (AIM396-S...
ML Best Practices: Prepare Data, Build Models, and Manage Lifecycle (AIM396-S...Amazon Web Services
 
Galvanise NYC - Scaling R with Hadoop & Spark. V1.0
Galvanise NYC - Scaling R with Hadoop & Spark. V1.0Galvanise NYC - Scaling R with Hadoop & Spark. V1.0
Galvanise NYC - Scaling R with Hadoop & Spark. V1.0vithakur
 
Intake 38 data access 5
Intake 38 data access 5Intake 38 data access 5
Intake 38 data access 5Mahmoud Ouf
 
JavaOne 2013: Memory Efficient Java
JavaOne 2013: Memory Efficient JavaJavaOne 2013: Memory Efficient Java
JavaOne 2013: Memory Efficient JavaChris Bailey
 
Odsc london data science bootcamp with pixie dust
Odsc london data science bootcamp with pixie dustOdsc london data science bootcamp with pixie dust
Odsc london data science bootcamp with pixie dustDavid Taieb
 
Inteligencia artificial, open source e IBM Call for Code
Inteligencia artificial, open source e IBM Call for CodeInteligencia artificial, open source e IBM Call for Code
Inteligencia artificial, open source e IBM Call for CodeLuciano Resende
 
Batch uploading to the Internet Archive using Python
Batch uploading to the Internet Archive using PythonBatch uploading to the Internet Archive using Python
Batch uploading to the Internet Archive using PythonAlison Harvey
 
Declarative Machine Learning: Bring your own Syntax, Algorithm, Data and Infr...
Declarative Machine Learning: Bring your own Syntax, Algorithm, Data and Infr...Declarative Machine Learning: Bring your own Syntax, Algorithm, Data and Infr...
Declarative Machine Learning: Bring your own Syntax, Algorithm, Data and Infr...Turi, Inc.
 
building-a-fdm-application-for-a-hfm-target
 building-a-fdm-application-for-a-hfm-target building-a-fdm-application-for-a-hfm-target
building-a-fdm-application-for-a-hfm-targetSid Mehta
 
Construindo Aplicações Deep Learning com TensorFlow e Amazon SageMaker - MCL...
Construindo Aplicações Deep Learning com TensorFlow e Amazon SageMaker -  MCL...Construindo Aplicações Deep Learning com TensorFlow e Amazon SageMaker -  MCL...
Construindo Aplicações Deep Learning com TensorFlow e Amazon SageMaker - MCL...Amazon Web Services
 
Dart for Java Developers
Dart for Java DevelopersDart for Java Developers
Dart for Java DevelopersYakov Fain
 

Similar to Pandas meetup 20200908 (20)

Import contents, taxonomies and translations in Drupal8
Import contents, taxonomies and translations in Drupal8Import contents, taxonomies and translations in Drupal8
Import contents, taxonomies and translations in Drupal8
 
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
 
Data Analysis with Python Pandas
Data Analysis with Python PandasData Analysis with Python Pandas
Data Analysis with Python Pandas
 
"R & Text Analytics" (15 January 2013)
"R & Text Analytics" (15 January 2013)"R & Text Analytics" (15 January 2013)
"R & Text Analytics" (15 January 2013)
 
Hivemall Talk at TD tech talk #3
Hivemall Talk at TD tech talk #3Hivemall Talk at TD tech talk #3
Hivemall Talk at TD tech talk #3
 
Introduction to Hivemall
Introduction to HivemallIntroduction to Hivemall
Introduction to Hivemall
 
Functional programming in Java
Functional programming in Java  Functional programming in Java
Functional programming in Java
 
A framework used to bridge between the language of business and PLCS
A framework used to bridge between the language of business and PLCSA framework used to bridge between the language of business and PLCS
A framework used to bridge between the language of business and PLCS
 
ML Best Practices: Prepare Data, Build Models, and Manage Lifecycle (AIM396-S...
ML Best Practices: Prepare Data, Build Models, and Manage Lifecycle (AIM396-S...ML Best Practices: Prepare Data, Build Models, and Manage Lifecycle (AIM396-S...
ML Best Practices: Prepare Data, Build Models, and Manage Lifecycle (AIM396-S...
 
Galvanise NYC - Scaling R with Hadoop & Spark. V1.0
Galvanise NYC - Scaling R with Hadoop & Spark. V1.0Galvanise NYC - Scaling R with Hadoop & Spark. V1.0
Galvanise NYC - Scaling R with Hadoop & Spark. V1.0
 
Intake 38 data access 5
Intake 38 data access 5Intake 38 data access 5
Intake 38 data access 5
 
JavaOne 2013: Memory Efficient Java
JavaOne 2013: Memory Efficient JavaJavaOne 2013: Memory Efficient Java
JavaOne 2013: Memory Efficient Java
 
Odsc london data science bootcamp with pixie dust
Odsc london data science bootcamp with pixie dustOdsc london data science bootcamp with pixie dust
Odsc london data science bootcamp with pixie dust
 
Inteligencia artificial, open source e IBM Call for Code
Inteligencia artificial, open source e IBM Call for CodeInteligencia artificial, open source e IBM Call for Code
Inteligencia artificial, open source e IBM Call for Code
 
Batch uploading to the Internet Archive using Python
Batch uploading to the Internet Archive using PythonBatch uploading to the Internet Archive using Python
Batch uploading to the Internet Archive using Python
 
Declarative Machine Learning: Bring your own Syntax, Algorithm, Data and Infr...
Declarative Machine Learning: Bring your own Syntax, Algorithm, Data and Infr...Declarative Machine Learning: Bring your own Syntax, Algorithm, Data and Infr...
Declarative Machine Learning: Bring your own Syntax, Algorithm, Data and Infr...
 
building-a-fdm-application-for-a-hfm-target
 building-a-fdm-application-for-a-hfm-target building-a-fdm-application-for-a-hfm-target
building-a-fdm-application-for-a-hfm-target
 
Typed data in drupal 8
Typed data in drupal 8Typed data in drupal 8
Typed data in drupal 8
 
Construindo Aplicações Deep Learning com TensorFlow e Amazon SageMaker - MCL...
Construindo Aplicações Deep Learning com TensorFlow e Amazon SageMaker -  MCL...Construindo Aplicações Deep Learning com TensorFlow e Amazon SageMaker -  MCL...
Construindo Aplicações Deep Learning com TensorFlow e Amazon SageMaker - MCL...
 
Dart for Java Developers
Dart for Java DevelopersDart for Java Developers
Dart for Java Developers
 

More from Haim Michael

Virtual Threads in Java
Virtual Threads in JavaVirtual Threads in Java
Virtual Threads in JavaHaim Michael
 
MongoDB Design Patterns
MongoDB Design PatternsMongoDB Design Patterns
MongoDB Design PatternsHaim Michael
 
Introduction to SQL Injections
Introduction to SQL InjectionsIntroduction to SQL Injections
Introduction to SQL InjectionsHaim Michael
 
Record Classes in Java
Record Classes in JavaRecord Classes in Java
Record Classes in JavaHaim Michael
 
Microservices Design Patterns
Microservices Design PatternsMicroservices Design Patterns
Microservices Design PatternsHaim Michael
 
OOP Best Practices in JavaScript
OOP Best Practices in JavaScriptOOP Best Practices in JavaScript
OOP Best Practices in JavaScriptHaim Michael
 
JavaScript Jump Start 20220214
JavaScript Jump Start 20220214JavaScript Jump Start 20220214
JavaScript Jump Start 20220214Haim Michael
 
Bootstrap Jump Start
Bootstrap Jump StartBootstrap Jump Start
Bootstrap Jump StartHaim Michael
 
What is new in PHP
What is new in PHPWhat is new in PHP
What is new in PHPHaim Michael
 
What is new in Python 3.9
What is new in Python 3.9What is new in Python 3.9
What is new in Python 3.9Haim Michael
 
Programming in Python on Steroid
Programming in Python on SteroidProgramming in Python on Steroid
Programming in Python on SteroidHaim Michael
 
The matplotlib Library
The matplotlib LibraryThe matplotlib Library
The matplotlib LibraryHaim Michael
 
Jupyter notebook 20200728
Jupyter notebook 20200728Jupyter notebook 20200728
Jupyter notebook 20200728Haim Michael
 
Node.js Crash Course (Jump Start)
Node.js Crash Course (Jump Start) Node.js Crash Course (Jump Start)
Node.js Crash Course (Jump Start) Haim Michael
 
The Power of Decorators in Python [Meetup]
The Power of Decorators in Python [Meetup]The Power of Decorators in Python [Meetup]
The Power of Decorators in Python [Meetup]Haim Michael
 
Asynchronous JavaScript Programming
Asynchronous JavaScript ProgrammingAsynchronous JavaScript Programming
Asynchronous JavaScript ProgrammingHaim Michael
 
WordPress Jump Start
WordPress Jump StartWordPress Jump Start
WordPress Jump StartHaim Michael
 

More from Haim Michael (20)

Anti Patterns
Anti PatternsAnti Patterns
Anti Patterns
 
Virtual Threads in Java
Virtual Threads in JavaVirtual Threads in Java
Virtual Threads in Java
 
MongoDB Design Patterns
MongoDB Design PatternsMongoDB Design Patterns
MongoDB Design Patterns
 
Introduction to SQL Injections
Introduction to SQL InjectionsIntroduction to SQL Injections
Introduction to SQL Injections
 
Record Classes in Java
Record Classes in JavaRecord Classes in Java
Record Classes in Java
 
Microservices Design Patterns
Microservices Design PatternsMicroservices Design Patterns
Microservices Design Patterns
 
OOP Best Practices in JavaScript
OOP Best Practices in JavaScriptOOP Best Practices in JavaScript
OOP Best Practices in JavaScript
 
Java Jump Start
Java Jump StartJava Jump Start
Java Jump Start
 
JavaScript Jump Start 20220214
JavaScript Jump Start 20220214JavaScript Jump Start 20220214
JavaScript Jump Start 20220214
 
Bootstrap Jump Start
Bootstrap Jump StartBootstrap Jump Start
Bootstrap Jump Start
 
What is new in PHP
What is new in PHPWhat is new in PHP
What is new in PHP
 
What is new in Python 3.9
What is new in Python 3.9What is new in Python 3.9
What is new in Python 3.9
 
Programming in Python on Steroid
Programming in Python on SteroidProgramming in Python on Steroid
Programming in Python on Steroid
 
The matplotlib Library
The matplotlib LibraryThe matplotlib Library
The matplotlib Library
 
Jupyter notebook 20200728
Jupyter notebook 20200728Jupyter notebook 20200728
Jupyter notebook 20200728
 
Node.js Crash Course (Jump Start)
Node.js Crash Course (Jump Start) Node.js Crash Course (Jump Start)
Node.js Crash Course (Jump Start)
 
The Power of Decorators in Python [Meetup]
The Power of Decorators in Python [Meetup]The Power of Decorators in Python [Meetup]
The Power of Decorators in Python [Meetup]
 
Asynchronous JavaScript Programming
Asynchronous JavaScript ProgrammingAsynchronous JavaScript Programming
Asynchronous JavaScript Programming
 
Python Jump Start
Python Jump StartPython Jump Start
Python Jump Start
 
WordPress Jump Start
WordPress Jump StartWordPress Jump Start
WordPress Jump Start
 

Recently uploaded

Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...masabamasaba
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyviewmasabamasaba
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is insideshinachiaurasa2
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 

Recently uploaded (20)

Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 

Pandas meetup 20200908

  • 1. The pandas Library Haim Michael September 8th , 2020 All logos, trade marks and brand names used in this presentation belong to the respective owners. lifemichael https://youtu.be/Go_6xXYEtkw
  • 2. © 2008 Haim Michael 20150729 What is Pandas?  Pandas is a fast, powerful, flexible and easy to use open source data analysis and manipulation tool, built on top of the Python programming language. (pandas.pydata.org)
  • 3. © 2008 Haim Michael 20150729 Installing Pandas  There are more than a few ways to install Pandas. The simplest would be using the pip utility. pip install pandas
  • 4. © 2008 Haim Michael 20150729 Checking Pandas Version  You can easily check the version of the Pandas library you already have installed using the following code.  The expected output should look like the following:
  • 5. © 2008 Haim Michael 20150729 Importing Pandas  In order to use Pandas we should first importing it. It is a common practice to import it using the alias pd. import pandas as pd
  • 6. © 2008 Haim Michael 20150729 The DataFrame Class  When instantiating the DataFrame class we will get an object that represents a table. import pandas as pd df = pd.DataFrame({ "country":["israel","france","germany"], "currency":["ils","euro","euro"], "capitol":["jerusalem","paris","berlin"] }) print(df)
  • 7. © 2008 Haim Michael 20150729 The Series Class  Each and every column of a DataFrame object is represented using a Series object. import pandas as pd marks = pd.Series([88,90,72,64], name="Mark") print(marks)
  • 8. © 2008 Haim Michael 20150729 The describe() Function  We can invoke this method both on a Series object and on a DataFrame object. Calling this function we will get a detailed statistic description. import pandas as pd marks = pd.Series([88,90,72,64], name="Mark") print(marks.describe())
  • 9. © 2008 Haim Michael 20150729 Reading & Writing Data  The available methods allow us to read data from files in various formats directly into a DataFrame object, and to write data we already have in a DataFrame object directly to files in various formats.
  • 10. © 2008 Haim Michael 20150729 Reading & Writing Data  The to_excel, to_csv, etc... are methods that we invoke on a DataFrame object. These methods allow us to to write the data we already have organized in a DataFrame object to a new file of a specific format.  The read_excel, read_csv, etc... are public methods that were defined in the pandas module.
  • 11. © 2008 Haim Michael 20150729 Writing to Excel Sample import pandas as pd df = pd.DataFrame({ "country":["israel","france","germany"], "currency":["ils","euro","euro"], "capitol":["jerusalem","paris","berlin"] } ) df.to_excel("countries.xlsx")
  • 12. © 2008 Haim Michael 20150729 Reading from CSV import pandas as pd ob = pd.read_csv("countries.csv") print(ob)
  • 13. © 2008 Haim Michael 20150729 Selecting Column  Selecting a column is done by using square brackets together with the column name of the column of interest. Each column is represented using an object of the type Series.
  • 14. © 2008 Haim Michael 20150729 Selecting Column import pandas as pd df = pd.DataFrame({ "country":["israel","france","germany"], "currency":["ils","euro","euro"], "capitol":["jerusalem","paris","berlin"] } ) countries = df["country"] print(countries) print(type(countries)
  • 15. © 2008 Haim Michael 20150729 Selecting Columns  Selecting multiple columns is done by using a list of column names.
  • 16. © 2008 Haim Michael 20150729 Selecting Columns import pandas as pd df = pd.DataFrame({ "country":["israel","france","germany"], "currency":["ils","euro","euro"], "capitol":["jerusalem","paris","berlin"] } ) ob = df[["country","capitol"]] print(ob) print(type(ob))
  • 17. © 2008 Haim Michael 20150729 Selecting Rows  Selecting rows based on a specific condition is done using a condition we specify inside the selection brackets.
  • 18. © 2008 Haim Michael 20150729 Selecting Rows import pandas as pd df = pd.DataFrame({ "first name":["moshe","daniel","tal"], "last name":["israeli","cohen","lahat"], "id":["234234","645645","678678"], "average":[85,90,64] } ) beststudents = df[df["average"]>80] print(beststudents) print(type(beststudents))
  • 19. © 2008 Haim Michael 20150729 Selecting Rows  Selecting rows that a specific column in the selected row has a value which is a specific value.
  • 20. © 2008 Haim Michael 20150729 Selecting Rows import pandas as pd df = pd.DataFrame({ "first name":["moshe","daniel","tal","jane"], "last name":["israeli","cohen","lahat","lala"], "id":["234234","645645","678678","234234"], "class":["1st","1st","2nd","3rd"] } ) premiumpassengers = df[(df["class"] == "1st") | (df["class"] == "3rd")] print(premiumpassengers) print(type(premiumpassengers))
  • 21. © 2008 Haim Michael 20150729 Selecting Multiple Rows & Cols  In order to select multiple rows and cols, a subset of our data, we should use the iloc operator.
  • 22. © 2008 Haim Michael 20150729 Selecting Multiple Rows & Cols import pandas as pd df = pd.DataFrame({ "first name":["moshe","daniel","tal"], "last name":["israeli","cohen","lahat"], "id":["234234","645645","678678"], "class":["1st","1st","2nd"] } ) ob = df.iloc[0:2,0:2] print(ob) print(type(ob))