SlideShare a Scribd company logo
1 of 24
Download to read offline
Data manipulation:
Pandas
AAA-Python Edition
Plan
●
1- Pandas: Series
●
2- Pandas: DataFrame
●
3- Indexing and Reindexing
●
4- Some operations
●
5- Google colab help
3
1-PandasSeries
[By Amina Delali]
pandas
●
pandas is a library that defnes data structures and
manipulation tools to be used in Python. It is often combined with
other numerical libraries like Numpy.
●
In pandas we can work with tabular or heterogeneous data by
using for example its defned structures DataFrame.
●
The other important pandas structure is: Series structure
●
Each of the two previous structures are used with an other defned
object in pandas: Index object.
Importing the
two modules
corresponding
to the structures
as S and DF
Giving only a
list as a
Parameter,
default indexes
were created
A default column label
4
1-PandasSeries
[By Amina Delali]
Series
●
A Series is a sequence of values of the same type associated
with a sequence of labels called index.
The default index created
Creating a list from a string
==> a list of characters
The length of the
index must be equal
to the list’s length
“his” is one scalar
value ==> the index
can be greater than one
5
1-PandasSeries
[By Amina Delali]
Series
The sorted dictionary
keys will be the series’
Index (the series values
will be sorted according
to this index)
If the key exists, the
Corresponding value is
Added.
If it doesn’t exist, a Nan
Value will be added
If a key is missed, its
corresponding value will not
be added
Same length as ndarray length
6
2-PandasDataFrame
[By Amina Delali]
DataFrame
●
A DataFrame is rectangular table of data organized in rows
and columns associated with rows and columns indexes
respectively.
The lists are not of the same dtype
neither the same length
Missing values
List of 3 lists
==>3 rows
The maximum lists lengths == 5
==> 5 columns
Both lines and columns
can have different dtype
(heterogeneous data type)
In this case,
each column
has different
dtypes
7
2-PandasDataFrame
[By Amina Delali]
DataFrame
●
List of 2 Series
==> 2 rows
Column indexes:
3 different values
of indexes ==> 3
columns
Number of Keys
== 2 ==>
Number of
Columns == 2
Lists must have same length:
Lists’ length == 3
==> number of rows == 3
One row has different dtypes
8
2-PandasDataFrame
[By Amina Delali]
DataFrame
●
2 Outer Keys == 2 Columns
6 different inner keys ==
6 rows
Missing values: the dicts
have different keys
Selecting
the rows 1
And 2
Selecting the
column Verbs
9
3-Indexingand
reindexing
[By Amina Delali]
. Indexing and fltering in Series
This index wasn’t
specified in the
creation of the series
Using the default index
will not produce the
same results:
10
3-Indexingand
reindexing
[By Amina Delali]
●
Indexing and fltering in DataFrame
Access to a
column as attribute
11
3-Indexingand
reindexing
[By Amina Delali]
●
Indexing and fltering in DataFrame
Selecting values
corresponding to True
12
3-Indexingand
reindexing
[By Amina Delali]
●
Indexing and fltering in DataFrame
13
3-Indexingand
reindexing
[By Amina Delali]
●
Indexing and fltering in DataFrame
●
●
The following table will summarize the indexation possibilities:
Indexing
Using labels Using default indexes
directly loc directly iloc
On value X and at method X and iat method
One row X Using a slice X
One column X X X
A slice of rows X X X X
A slice of columns X X
A portion X X
A list of rows X X
A list of columns X X X
14
3-Indexingand
reindexing
[By Amina Delali]
●
Reindexing: creating a new Series or DataFrame
by changing the order of a given Series or
DataFrame values.
Before
After
A new value created
with the ffill method
Before
After
A new value created
with the given fill_value
15
4-SomeOperations
[By Amina Delali]
●
Dropping: creating a new Series or DataFrame
by dropping the rows or columns of a given Series or
DataFrame.
Before
After
Before
After
Creating a DataFrame
specifying a 2 dimensional
ndarray as argument
Deleted column
Deleted rows
16
4-SomeOperations
[By Amina Delali]
Some other operations
●
We can apply arithmetic operations using operators or defned
methods:
df1 doesn’t
have r3 row
The missing values
in df1 were replace
by 1 then added
to r3 df2’s row
17
4-SomeOperations
[By Amina Delali]
Some other operations The same method
exists in DataFrame
Missing value in
ser2
Dividing ser2 values
by ser1 values
Dividing ser2 values
by ser1 values
Add row by row,
matching columns
labels
If axis =0, will add
column by column
Matching rows labels
18
4-SomeOperations
[By Amina Delali]
●
we can apply functions on pandas structures just by using the structures
as arguments or by using the: apply , map or the applymap method.
Apply to each
column
Defined for Series
Apply to
each
element
19
4-SomeOperations
[By Amina Delali]
Sorting and Ranking
●
The pandas structures can be sorted either by indexes or by values
●
The values can also be ranked considering their position in a sorting
The indexes
were sorted
(so their
corresponding
rows)
The column
c2
was sorted
6 is at the 5th
and 6th
position,so it is ranked
the mean of those
Positions (5 + 6)/2 == 5.5
20
4-SomeOperations
[By Amina Delali]
Descriptive operations
●
There is a set of methods and functions that produce some
descriptive values about the data contained in the
corresponding structure.
The unique different
Value is 1
There are 5 “1”
21
4-SomeOperations
[By Amina Delali]
Descriptive operations
[r1,c3] and[r2,c1]
are in [2,3]
c and d are
In [2,3]
22
5-GoogleColab
Help
[By Amina Delali]
●
Google Colab allows us to see the list of the available modules
and function in a given module.
●
It allows us also to access to the help of a given function or
attribute.
The name of the module:
np followed by a dot: .
So: np.
followed by a tabulation
(key)
The name of the
function or attribute
followed by the “?”
and run, will display
this help
References
●
Wes McKinney. Python for data analysis: Data wrangling
with Pandas, NumPy, and IPython. O’Reilly Media, Inc, 2018.
Thank
you!
FOR ALL YOUR TIME

More Related Content

What's hot

Java Tutorial Lab 7
Java Tutorial Lab 7Java Tutorial Lab 7
Java Tutorial Lab 7Berk Soysal
 
Unit 2 linked list
Unit 2   linked listUnit 2   linked list
Unit 2 linked listDrkhanchanaR
 
Stacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURESStacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURESSowmya Jyothi
 
Data structure and its types
Data structure and its typesData structure and its types
Data structure and its typesNavtar Sidhu Brar
 
Data structure & its types
Data structure & its typesData structure & its types
Data structure & its typesRameesha Sadaqat
 
Data Structure Using C
Data Structure Using CData Structure Using C
Data Structure Using Ccpjcollege
 
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...Balwant Gorad
 
List Data Structure
List Data StructureList Data Structure
List Data StructureZidny Nafan
 
Bca data structures linked list mrs.sowmya jyothi
Bca data structures linked list mrs.sowmya jyothiBca data structures linked list mrs.sowmya jyothi
Bca data structures linked list mrs.sowmya jyothiSowmya Jyothi
 
Java presentation on insertion sort
Java presentation on insertion sortJava presentation on insertion sort
Java presentation on insertion sort_fahad_shaikh
 
What is Link list? explained with animations
What is Link list? explained with animationsWhat is Link list? explained with animations
What is Link list? explained with animationsPratikNaik41
 
R DATA STRUCTURES 1
R DATA STRUCTURES 1R DATA STRUCTURES 1
R DATA STRUCTURES 1Milind M
 
Data Structures- Part7 linked lists
Data Structures- Part7 linked listsData Structures- Part7 linked lists
Data Structures- Part7 linked listsAbdullah Al-hazmy
 
R DATA STRUCTURES 2
R DATA STRUCTURES 2R DATA STRUCTURES 2
R DATA STRUCTURES 2Milind M
 

What's hot (20)

Java Tutorial Lab 7
Java Tutorial Lab 7Java Tutorial Lab 7
Java Tutorial Lab 7
 
Unit 2 linked list
Unit 2   linked listUnit 2   linked list
Unit 2 linked list
 
Stacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURESStacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURES
 
Data structure and its types
Data structure and its typesData structure and its types
Data structure and its types
 
single linked list
single linked listsingle linked list
single linked list
 
R Datatypes
R DatatypesR Datatypes
R Datatypes
 
Data structure & its types
Data structure & its typesData structure & its types
Data structure & its types
 
Data Structure Using C
Data Structure Using CData Structure Using C
Data Structure Using C
 
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
 
Linked Lists
Linked ListsLinked Lists
Linked Lists
 
List Data Structure
List Data StructureList Data Structure
List Data Structure
 
Sql ppt
Sql pptSql ppt
Sql ppt
 
Bca data structures linked list mrs.sowmya jyothi
Bca data structures linked list mrs.sowmya jyothiBca data structures linked list mrs.sowmya jyothi
Bca data structures linked list mrs.sowmya jyothi
 
R data types
R data typesR data types
R data types
 
Java presentation on insertion sort
Java presentation on insertion sortJava presentation on insertion sort
Java presentation on insertion sort
 
Sorting
SortingSorting
Sorting
 
What is Link list? explained with animations
What is Link list? explained with animationsWhat is Link list? explained with animations
What is Link list? explained with animations
 
R DATA STRUCTURES 1
R DATA STRUCTURES 1R DATA STRUCTURES 1
R DATA STRUCTURES 1
 
Data Structures- Part7 linked lists
Data Structures- Part7 linked listsData Structures- Part7 linked lists
Data Structures- Part7 linked lists
 
R DATA STRUCTURES 2
R DATA STRUCTURES 2R DATA STRUCTURES 2
R DATA STRUCTURES 2
 

Similar to Aaa ped-5-Data manipulation: Pandas

Aaa ped-8- Data manipulation: Data wrangling, aggregation, and group operations
Aaa ped-8- Data manipulation: Data wrangling, aggregation, and group operationsAaa ped-8- Data manipulation: Data wrangling, aggregation, and group operations
Aaa ped-8- Data manipulation: Data wrangling, aggregation, and group operationsAminaRepo
 
Aaa ped-6-Data manipulation: Data Files, and Data Cleaning & Preparation
Aaa ped-6-Data manipulation:  Data Files, and Data Cleaning & PreparationAaa ped-6-Data manipulation:  Data Files, and Data Cleaning & Preparation
Aaa ped-6-Data manipulation: Data Files, and Data Cleaning & PreparationAminaRepo
 
Unit 3_Numpy_Vsp.pptx
Unit 3_Numpy_Vsp.pptxUnit 3_Numpy_Vsp.pptx
Unit 3_Numpy_Vsp.pptxprakashvs7
 
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.pptxKirti Verma
 
pandas-221217084954-937bb582.pdf
pandas-221217084954-937bb582.pdfpandas-221217084954-937bb582.pdf
pandas-221217084954-937bb582.pdfscorsam1
 
2. Data Preprocessing with Numpy and Pandas.pptx
2. Data Preprocessing with Numpy and Pandas.pptx2. Data Preprocessing with Numpy and Pandas.pptx
2. Data Preprocessing with Numpy and Pandas.pptxPeangSereysothirich
 
Lecture on Python Pandas for Decision Making
Lecture on Python Pandas for Decision MakingLecture on Python Pandas for Decision Making
Lecture on Python Pandas for Decision Makingssuser46aec4
 
Lecture 1 Pandas Basics.pptx machine learning
Lecture 1 Pandas Basics.pptx machine learningLecture 1 Pandas Basics.pptx machine learning
Lecture 1 Pandas Basics.pptx machine learningmy6305874
 
Aaa ped-4- Data manipulation: Numpy
Aaa ped-4- Data manipulation: Numpy Aaa ped-4- Data manipulation: Numpy
Aaa ped-4- Data manipulation: Numpy AminaRepo
 
XII IP New PYTHN Python Pandas 2020-21.pptx
XII IP New PYTHN Python Pandas 2020-21.pptxXII IP New PYTHN Python Pandas 2020-21.pptx
XII IP New PYTHN Python Pandas 2020-21.pptxlekha572836
 
Aaa ped-Data-8- manipulation: Plotting and Visualization
Aaa ped-Data-8- manipulation: Plotting and VisualizationAaa ped-Data-8- manipulation: Plotting and Visualization
Aaa ped-Data-8- manipulation: Plotting and VisualizationAminaRepo
 
Lecture 3 intro2data
Lecture 3 intro2dataLecture 3 intro2data
Lecture 3 intro2dataJohnson Ubah
 

Similar to Aaa ped-5-Data manipulation: Pandas (20)

Aaa ped-8- Data manipulation: Data wrangling, aggregation, and group operations
Aaa ped-8- Data manipulation: Data wrangling, aggregation, and group operationsAaa ped-8- Data manipulation: Data wrangling, aggregation, and group operations
Aaa ped-8- Data manipulation: Data wrangling, aggregation, and group operations
 
Aaa ped-6-Data manipulation: Data Files, and Data Cleaning & Preparation
Aaa ped-6-Data manipulation:  Data Files, and Data Cleaning & PreparationAaa ped-6-Data manipulation:  Data Files, and Data Cleaning & Preparation
Aaa ped-6-Data manipulation: Data Files, and Data Cleaning & Preparation
 
Pandas csv
Pandas csvPandas csv
Pandas csv
 
Unit 3_Numpy_Vsp.pptx
Unit 3_Numpy_Vsp.pptxUnit 3_Numpy_Vsp.pptx
Unit 3_Numpy_Vsp.pptx
 
Unit 3_Numpy_VP.pptx
Unit 3_Numpy_VP.pptxUnit 3_Numpy_VP.pptx
Unit 3_Numpy_VP.pptx
 
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
 
Lecture 9.pptx
Lecture 9.pptxLecture 9.pptx
Lecture 9.pptx
 
Pandas.pptx
Pandas.pptxPandas.pptx
Pandas.pptx
 
pandas-221217084954-937bb582.pdf
pandas-221217084954-937bb582.pdfpandas-221217084954-937bb582.pdf
pandas-221217084954-937bb582.pdf
 
Unit 3_Numpy_VP.pptx
Unit 3_Numpy_VP.pptxUnit 3_Numpy_VP.pptx
Unit 3_Numpy_VP.pptx
 
2. Data Preprocessing with Numpy and Pandas.pptx
2. Data Preprocessing with Numpy and Pandas.pptx2. Data Preprocessing with Numpy and Pandas.pptx
2. Data Preprocessing with Numpy and Pandas.pptx
 
Lecture on Python Pandas for Decision Making
Lecture on Python Pandas for Decision MakingLecture on Python Pandas for Decision Making
Lecture on Python Pandas for Decision Making
 
Lecture 1 Pandas Basics.pptx machine learning
Lecture 1 Pandas Basics.pptx machine learningLecture 1 Pandas Basics.pptx machine learning
Lecture 1 Pandas Basics.pptx machine learning
 
Aaa ped-4- Data manipulation: Numpy
Aaa ped-4- Data manipulation: Numpy Aaa ped-4- Data manipulation: Numpy
Aaa ped-4- Data manipulation: Numpy
 
XII IP New PYTHN Python Pandas 2020-21.pptx
XII IP New PYTHN Python Pandas 2020-21.pptxXII IP New PYTHN Python Pandas 2020-21.pptx
XII IP New PYTHN Python Pandas 2020-21.pptx
 
Aaa ped-Data-8- manipulation: Plotting and Visualization
Aaa ped-Data-8- manipulation: Plotting and VisualizationAaa ped-Data-8- manipulation: Plotting and Visualization
Aaa ped-Data-8- manipulation: Plotting and Visualization
 
ppanda.pptx
ppanda.pptxppanda.pptx
ppanda.pptx
 
Lecture 3 intro2data
Lecture 3 intro2dataLecture 3 intro2data
Lecture 3 intro2data
 
interenship.pptx
interenship.pptxinterenship.pptx
interenship.pptx
 
4)12th_L-1_PYTHON-PANDAS-I.pptx
4)12th_L-1_PYTHON-PANDAS-I.pptx4)12th_L-1_PYTHON-PANDAS-I.pptx
4)12th_L-1_PYTHON-PANDAS-I.pptx
 

More from AminaRepo

Aaa ped-23-Artificial Neural Network: Keras and Tensorfow
Aaa ped-23-Artificial Neural Network: Keras and TensorfowAaa ped-23-Artificial Neural Network: Keras and Tensorfow
Aaa ped-23-Artificial Neural Network: Keras and TensorfowAminaRepo
 
Aaa ped-22-Artificial Neural Network: Introduction to ANN
Aaa ped-22-Artificial Neural Network: Introduction to ANNAaa ped-22-Artificial Neural Network: Introduction to ANN
Aaa ped-22-Artificial Neural Network: Introduction to ANNAminaRepo
 
Aaa ped-21-Recommender Systems: Content-based Filtering
Aaa ped-21-Recommender Systems: Content-based FilteringAaa ped-21-Recommender Systems: Content-based Filtering
Aaa ped-21-Recommender Systems: Content-based FilteringAminaRepo
 
Aaa ped-20-Recommender Systems: Model-based collaborative filtering
Aaa ped-20-Recommender Systems: Model-based collaborative filteringAaa ped-20-Recommender Systems: Model-based collaborative filtering
Aaa ped-20-Recommender Systems: Model-based collaborative filteringAminaRepo
 
Aaa ped-19-Recommender Systems: Neighborhood-based Filtering
Aaa ped-19-Recommender Systems: Neighborhood-based FilteringAaa ped-19-Recommender Systems: Neighborhood-based Filtering
Aaa ped-19-Recommender Systems: Neighborhood-based FilteringAminaRepo
 
Aaa ped-18-Unsupervised Learning: Association Rule Learning
Aaa ped-18-Unsupervised Learning: Association Rule LearningAaa ped-18-Unsupervised Learning: Association Rule Learning
Aaa ped-18-Unsupervised Learning: Association Rule LearningAminaRepo
 
Aaa ped-17-Unsupervised Learning: Dimensionality reduction
Aaa ped-17-Unsupervised Learning: Dimensionality reductionAaa ped-17-Unsupervised Learning: Dimensionality reduction
Aaa ped-17-Unsupervised Learning: Dimensionality reductionAminaRepo
 
Aaa ped-16-Unsupervised Learning: clustering
Aaa ped-16-Unsupervised Learning: clusteringAaa ped-16-Unsupervised Learning: clustering
Aaa ped-16-Unsupervised Learning: clusteringAminaRepo
 
Aaa ped-15-Ensemble Learning: Random Forests
Aaa ped-15-Ensemble Learning: Random ForestsAaa ped-15-Ensemble Learning: Random Forests
Aaa ped-15-Ensemble Learning: Random ForestsAminaRepo
 
Aaa ped-14-Ensemble Learning: About Ensemble Learning
Aaa ped-14-Ensemble Learning: About Ensemble LearningAaa ped-14-Ensemble Learning: About Ensemble Learning
Aaa ped-14-Ensemble Learning: About Ensemble LearningAminaRepo
 
Aaa ped-12-Supervised Learning: Support Vector Machines & Naive Bayes Classifer
Aaa ped-12-Supervised Learning: Support Vector Machines & Naive Bayes ClassiferAaa ped-12-Supervised Learning: Support Vector Machines & Naive Bayes Classifer
Aaa ped-12-Supervised Learning: Support Vector Machines & Naive Bayes ClassiferAminaRepo
 
Aaa ped-11-Supervised Learning: Multivariable Regressor & Classifers
Aaa ped-11-Supervised Learning: Multivariable Regressor & ClassifersAaa ped-11-Supervised Learning: Multivariable Regressor & Classifers
Aaa ped-11-Supervised Learning: Multivariable Regressor & ClassifersAminaRepo
 
Aaa ped-10-Supervised Learning: Introduction to Supervised Learning
Aaa ped-10-Supervised Learning: Introduction to Supervised LearningAaa ped-10-Supervised Learning: Introduction to Supervised Learning
Aaa ped-10-Supervised Learning: Introduction to Supervised LearningAminaRepo
 
Aaa ped-9-Data manipulation: Time Series & Geographical visualization
Aaa ped-9-Data manipulation: Time Series & Geographical visualizationAaa ped-9-Data manipulation: Time Series & Geographical visualization
Aaa ped-9-Data manipulation: Time Series & Geographical visualizationAminaRepo
 
Aaa ped-3. Pythond: advanced concepts
Aaa ped-3. Pythond: advanced conceptsAaa ped-3. Pythond: advanced concepts
Aaa ped-3. Pythond: advanced conceptsAminaRepo
 
Aaa ped-2- Python: Basics
Aaa ped-2- Python: BasicsAaa ped-2- Python: Basics
Aaa ped-2- Python: BasicsAminaRepo
 
Aaa ped-1- Python: Introduction to AI, Python and Colab
Aaa ped-1- Python: Introduction to AI, Python and ColabAaa ped-1- Python: Introduction to AI, Python and Colab
Aaa ped-1- Python: Introduction to AI, Python and ColabAminaRepo
 
Aaa ped-24- Reinforcement Learning
Aaa ped-24- Reinforcement LearningAaa ped-24- Reinforcement Learning
Aaa ped-24- Reinforcement LearningAminaRepo
 

More from AminaRepo (18)

Aaa ped-23-Artificial Neural Network: Keras and Tensorfow
Aaa ped-23-Artificial Neural Network: Keras and TensorfowAaa ped-23-Artificial Neural Network: Keras and Tensorfow
Aaa ped-23-Artificial Neural Network: Keras and Tensorfow
 
Aaa ped-22-Artificial Neural Network: Introduction to ANN
Aaa ped-22-Artificial Neural Network: Introduction to ANNAaa ped-22-Artificial Neural Network: Introduction to ANN
Aaa ped-22-Artificial Neural Network: Introduction to ANN
 
Aaa ped-21-Recommender Systems: Content-based Filtering
Aaa ped-21-Recommender Systems: Content-based FilteringAaa ped-21-Recommender Systems: Content-based Filtering
Aaa ped-21-Recommender Systems: Content-based Filtering
 
Aaa ped-20-Recommender Systems: Model-based collaborative filtering
Aaa ped-20-Recommender Systems: Model-based collaborative filteringAaa ped-20-Recommender Systems: Model-based collaborative filtering
Aaa ped-20-Recommender Systems: Model-based collaborative filtering
 
Aaa ped-19-Recommender Systems: Neighborhood-based Filtering
Aaa ped-19-Recommender Systems: Neighborhood-based FilteringAaa ped-19-Recommender Systems: Neighborhood-based Filtering
Aaa ped-19-Recommender Systems: Neighborhood-based Filtering
 
Aaa ped-18-Unsupervised Learning: Association Rule Learning
Aaa ped-18-Unsupervised Learning: Association Rule LearningAaa ped-18-Unsupervised Learning: Association Rule Learning
Aaa ped-18-Unsupervised Learning: Association Rule Learning
 
Aaa ped-17-Unsupervised Learning: Dimensionality reduction
Aaa ped-17-Unsupervised Learning: Dimensionality reductionAaa ped-17-Unsupervised Learning: Dimensionality reduction
Aaa ped-17-Unsupervised Learning: Dimensionality reduction
 
Aaa ped-16-Unsupervised Learning: clustering
Aaa ped-16-Unsupervised Learning: clusteringAaa ped-16-Unsupervised Learning: clustering
Aaa ped-16-Unsupervised Learning: clustering
 
Aaa ped-15-Ensemble Learning: Random Forests
Aaa ped-15-Ensemble Learning: Random ForestsAaa ped-15-Ensemble Learning: Random Forests
Aaa ped-15-Ensemble Learning: Random Forests
 
Aaa ped-14-Ensemble Learning: About Ensemble Learning
Aaa ped-14-Ensemble Learning: About Ensemble LearningAaa ped-14-Ensemble Learning: About Ensemble Learning
Aaa ped-14-Ensemble Learning: About Ensemble Learning
 
Aaa ped-12-Supervised Learning: Support Vector Machines & Naive Bayes Classifer
Aaa ped-12-Supervised Learning: Support Vector Machines & Naive Bayes ClassiferAaa ped-12-Supervised Learning: Support Vector Machines & Naive Bayes Classifer
Aaa ped-12-Supervised Learning: Support Vector Machines & Naive Bayes Classifer
 
Aaa ped-11-Supervised Learning: Multivariable Regressor & Classifers
Aaa ped-11-Supervised Learning: Multivariable Regressor & ClassifersAaa ped-11-Supervised Learning: Multivariable Regressor & Classifers
Aaa ped-11-Supervised Learning: Multivariable Regressor & Classifers
 
Aaa ped-10-Supervised Learning: Introduction to Supervised Learning
Aaa ped-10-Supervised Learning: Introduction to Supervised LearningAaa ped-10-Supervised Learning: Introduction to Supervised Learning
Aaa ped-10-Supervised Learning: Introduction to Supervised Learning
 
Aaa ped-9-Data manipulation: Time Series & Geographical visualization
Aaa ped-9-Data manipulation: Time Series & Geographical visualizationAaa ped-9-Data manipulation: Time Series & Geographical visualization
Aaa ped-9-Data manipulation: Time Series & Geographical visualization
 
Aaa ped-3. Pythond: advanced concepts
Aaa ped-3. Pythond: advanced conceptsAaa ped-3. Pythond: advanced concepts
Aaa ped-3. Pythond: advanced concepts
 
Aaa ped-2- Python: Basics
Aaa ped-2- Python: BasicsAaa ped-2- Python: Basics
Aaa ped-2- Python: Basics
 
Aaa ped-1- Python: Introduction to AI, Python and Colab
Aaa ped-1- Python: Introduction to AI, Python and ColabAaa ped-1- Python: Introduction to AI, Python and Colab
Aaa ped-1- Python: Introduction to AI, Python and Colab
 
Aaa ped-24- Reinforcement Learning
Aaa ped-24- Reinforcement LearningAaa ped-24- Reinforcement Learning
Aaa ped-24- Reinforcement Learning
 

Recently uploaded

GBSN - Microbiology (Unit 2)
GBSN - Microbiology (Unit 2)GBSN - Microbiology (Unit 2)
GBSN - Microbiology (Unit 2)Areesha Ahmad
 
❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.
❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.
❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.Nitya salvi
 
Biological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdfBiological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdfmuntazimhurra
 
DIFFERENCE IN BACK CROSS AND TEST CROSS
DIFFERENCE IN  BACK CROSS AND TEST CROSSDIFFERENCE IN  BACK CROSS AND TEST CROSS
DIFFERENCE IN BACK CROSS AND TEST CROSSLeenakshiTyagi
 
GBSN - Biochemistry (Unit 1)
GBSN - Biochemistry (Unit 1)GBSN - Biochemistry (Unit 1)
GBSN - Biochemistry (Unit 1)Areesha Ahmad
 
Hire 💕 9907093804 Hooghly Call Girls Service Call Girls Agency
Hire 💕 9907093804 Hooghly Call Girls Service Call Girls AgencyHire 💕 9907093804 Hooghly Call Girls Service Call Girls Agency
Hire 💕 9907093804 Hooghly Call Girls Service Call Girls AgencySheetal Arora
 
Physiochemical properties of nanomaterials and its nanotoxicity.pptx
Physiochemical properties of nanomaterials and its nanotoxicity.pptxPhysiochemical properties of nanomaterials and its nanotoxicity.pptx
Physiochemical properties of nanomaterials and its nanotoxicity.pptxAArockiyaNisha
 
VIRUSES structure and classification ppt by Dr.Prince C P
VIRUSES structure and classification ppt by Dr.Prince C PVIRUSES structure and classification ppt by Dr.Prince C P
VIRUSES structure and classification ppt by Dr.Prince C PPRINCE C P
 
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...anilsa9823
 
Animal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptxAnimal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptxUmerFayaz5
 
Formation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disksFormation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disksSérgio Sacani
 
Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )aarthirajkumar25
 
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43bNightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43bSérgio Sacani
 
Pests of cotton_Sucking_Pests_Dr.UPR.pdf
Pests of cotton_Sucking_Pests_Dr.UPR.pdfPests of cotton_Sucking_Pests_Dr.UPR.pdf
Pests of cotton_Sucking_Pests_Dr.UPR.pdfPirithiRaju
 
Botany krishna series 2nd semester Only Mcq type questions
Botany krishna series 2nd semester Only Mcq type questionsBotany krishna series 2nd semester Only Mcq type questions
Botany krishna series 2nd semester Only Mcq type questionsSumit Kumar yadav
 
Spermiogenesis or Spermateleosis or metamorphosis of spermatid
Spermiogenesis or Spermateleosis or metamorphosis of spermatidSpermiogenesis or Spermateleosis or metamorphosis of spermatid
Spermiogenesis or Spermateleosis or metamorphosis of spermatidSarthak Sekhar Mondal
 
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdfPests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdfPirithiRaju
 
Presentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptxPresentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptxgindu3009
 
Pests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdfPests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdfPirithiRaju
 
Botany 4th semester file By Sumit Kumar yadav.pdf
Botany 4th semester file By Sumit Kumar yadav.pdfBotany 4th semester file By Sumit Kumar yadav.pdf
Botany 4th semester file By Sumit Kumar yadav.pdfSumit Kumar yadav
 

Recently uploaded (20)

GBSN - Microbiology (Unit 2)
GBSN - Microbiology (Unit 2)GBSN - Microbiology (Unit 2)
GBSN - Microbiology (Unit 2)
 
❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.
❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.
❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.
 
Biological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdfBiological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdf
 
DIFFERENCE IN BACK CROSS AND TEST CROSS
DIFFERENCE IN  BACK CROSS AND TEST CROSSDIFFERENCE IN  BACK CROSS AND TEST CROSS
DIFFERENCE IN BACK CROSS AND TEST CROSS
 
GBSN - Biochemistry (Unit 1)
GBSN - Biochemistry (Unit 1)GBSN - Biochemistry (Unit 1)
GBSN - Biochemistry (Unit 1)
 
Hire 💕 9907093804 Hooghly Call Girls Service Call Girls Agency
Hire 💕 9907093804 Hooghly Call Girls Service Call Girls AgencyHire 💕 9907093804 Hooghly Call Girls Service Call Girls Agency
Hire 💕 9907093804 Hooghly Call Girls Service Call Girls Agency
 
Physiochemical properties of nanomaterials and its nanotoxicity.pptx
Physiochemical properties of nanomaterials and its nanotoxicity.pptxPhysiochemical properties of nanomaterials and its nanotoxicity.pptx
Physiochemical properties of nanomaterials and its nanotoxicity.pptx
 
VIRUSES structure and classification ppt by Dr.Prince C P
VIRUSES structure and classification ppt by Dr.Prince C PVIRUSES structure and classification ppt by Dr.Prince C P
VIRUSES structure and classification ppt by Dr.Prince C P
 
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
 
Animal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptxAnimal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptx
 
Formation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disksFormation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disks
 
Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )
 
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43bNightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
 
Pests of cotton_Sucking_Pests_Dr.UPR.pdf
Pests of cotton_Sucking_Pests_Dr.UPR.pdfPests of cotton_Sucking_Pests_Dr.UPR.pdf
Pests of cotton_Sucking_Pests_Dr.UPR.pdf
 
Botany krishna series 2nd semester Only Mcq type questions
Botany krishna series 2nd semester Only Mcq type questionsBotany krishna series 2nd semester Only Mcq type questions
Botany krishna series 2nd semester Only Mcq type questions
 
Spermiogenesis or Spermateleosis or metamorphosis of spermatid
Spermiogenesis or Spermateleosis or metamorphosis of spermatidSpermiogenesis or Spermateleosis or metamorphosis of spermatid
Spermiogenesis or Spermateleosis or metamorphosis of spermatid
 
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdfPests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
 
Presentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptxPresentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptx
 
Pests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdfPests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdf
 
Botany 4th semester file By Sumit Kumar yadav.pdf
Botany 4th semester file By Sumit Kumar yadav.pdfBotany 4th semester file By Sumit Kumar yadav.pdf
Botany 4th semester file By Sumit Kumar yadav.pdf
 

Aaa ped-5-Data manipulation: Pandas

  • 2. Plan ● 1- Pandas: Series ● 2- Pandas: DataFrame ● 3- Indexing and Reindexing ● 4- Some operations ● 5- Google colab help
  • 3. 3 1-PandasSeries [By Amina Delali] pandas ● pandas is a library that defnes data structures and manipulation tools to be used in Python. It is often combined with other numerical libraries like Numpy. ● In pandas we can work with tabular or heterogeneous data by using for example its defned structures DataFrame. ● The other important pandas structure is: Series structure ● Each of the two previous structures are used with an other defned object in pandas: Index object. Importing the two modules corresponding to the structures as S and DF Giving only a list as a Parameter, default indexes were created A default column label
  • 4. 4 1-PandasSeries [By Amina Delali] Series ● A Series is a sequence of values of the same type associated with a sequence of labels called index. The default index created Creating a list from a string ==> a list of characters The length of the index must be equal to the list’s length “his” is one scalar value ==> the index can be greater than one
  • 5. 5 1-PandasSeries [By Amina Delali] Series The sorted dictionary keys will be the series’ Index (the series values will be sorted according to this index) If the key exists, the Corresponding value is Added. If it doesn’t exist, a Nan Value will be added If a key is missed, its corresponding value will not be added Same length as ndarray length
  • 6. 6 2-PandasDataFrame [By Amina Delali] DataFrame ● A DataFrame is rectangular table of data organized in rows and columns associated with rows and columns indexes respectively. The lists are not of the same dtype neither the same length Missing values List of 3 lists ==>3 rows The maximum lists lengths == 5 ==> 5 columns Both lines and columns can have different dtype (heterogeneous data type) In this case, each column has different dtypes
  • 7. 7 2-PandasDataFrame [By Amina Delali] DataFrame ● List of 2 Series ==> 2 rows Column indexes: 3 different values of indexes ==> 3 columns Number of Keys == 2 ==> Number of Columns == 2 Lists must have same length: Lists’ length == 3 ==> number of rows == 3 One row has different dtypes
  • 8. 8 2-PandasDataFrame [By Amina Delali] DataFrame ● 2 Outer Keys == 2 Columns 6 different inner keys == 6 rows Missing values: the dicts have different keys Selecting the rows 1 And 2 Selecting the column Verbs
  • 9. 9 3-Indexingand reindexing [By Amina Delali] . Indexing and fltering in Series This index wasn’t specified in the creation of the series Using the default index will not produce the same results:
  • 10. 10 3-Indexingand reindexing [By Amina Delali] ● Indexing and fltering in DataFrame Access to a column as attribute
  • 11. 11 3-Indexingand reindexing [By Amina Delali] ● Indexing and fltering in DataFrame Selecting values corresponding to True
  • 13. 13 3-Indexingand reindexing [By Amina Delali] ● Indexing and fltering in DataFrame ● ● The following table will summarize the indexation possibilities: Indexing Using labels Using default indexes directly loc directly iloc On value X and at method X and iat method One row X Using a slice X One column X X X A slice of rows X X X X A slice of columns X X A portion X X A list of rows X X A list of columns X X X
  • 14. 14 3-Indexingand reindexing [By Amina Delali] ● Reindexing: creating a new Series or DataFrame by changing the order of a given Series or DataFrame values. Before After A new value created with the ffill method Before After A new value created with the given fill_value
  • 15. 15 4-SomeOperations [By Amina Delali] ● Dropping: creating a new Series or DataFrame by dropping the rows or columns of a given Series or DataFrame. Before After Before After Creating a DataFrame specifying a 2 dimensional ndarray as argument Deleted column Deleted rows
  • 16. 16 4-SomeOperations [By Amina Delali] Some other operations ● We can apply arithmetic operations using operators or defned methods: df1 doesn’t have r3 row The missing values in df1 were replace by 1 then added to r3 df2’s row
  • 17. 17 4-SomeOperations [By Amina Delali] Some other operations The same method exists in DataFrame Missing value in ser2 Dividing ser2 values by ser1 values Dividing ser2 values by ser1 values Add row by row, matching columns labels If axis =0, will add column by column Matching rows labels
  • 18. 18 4-SomeOperations [By Amina Delali] ● we can apply functions on pandas structures just by using the structures as arguments or by using the: apply , map or the applymap method. Apply to each column Defined for Series Apply to each element
  • 19. 19 4-SomeOperations [By Amina Delali] Sorting and Ranking ● The pandas structures can be sorted either by indexes or by values ● The values can also be ranked considering their position in a sorting The indexes were sorted (so their corresponding rows) The column c2 was sorted 6 is at the 5th and 6th position,so it is ranked the mean of those Positions (5 + 6)/2 == 5.5
  • 20. 20 4-SomeOperations [By Amina Delali] Descriptive operations ● There is a set of methods and functions that produce some descriptive values about the data contained in the corresponding structure. The unique different Value is 1 There are 5 “1”
  • 21. 21 4-SomeOperations [By Amina Delali] Descriptive operations [r1,c3] and[r2,c1] are in [2,3] c and d are In [2,3]
  • 22. 22 5-GoogleColab Help [By Amina Delali] ● Google Colab allows us to see the list of the available modules and function in a given module. ● It allows us also to access to the help of a given function or attribute. The name of the module: np followed by a dot: . So: np. followed by a tabulation (key) The name of the function or attribute followed by the “?” and run, will display this help
  • 23. References ● Wes McKinney. Python for data analysis: Data wrangling with Pandas, NumPy, and IPython. O’Reilly Media, Inc, 2018.