SlideShare a Scribd company logo
Python Library – Pandas
It is a most famous Python package for data science, which offers
powerful and flexible data structures that make data analysis and
manipulation easy. Pandas make data importing and data analyzing
much easier. Pandas build on packages like NumPy and matplotlib
to give us a single & convenient place for data analysis and
visualization work. Pandas is a high level data manipulation tool
developed by Wes McKinney.
SYLLABUS 2022-23
Basic Features of Panda
1. With a pandas dataframe, we can have different data types (float, int, string,
datetime, etc) all in one place
2. Columns from a Panda data structure can be deleted or inserted
3. Good IO capabilities; Easily pull data from a MySQL database directly into a
data frame
4. Itsupportsgroupbyoperationfordataaggregationandtransformationandalowshigh
performancemergingandjoiningofdata.
5. It can easily select subsets of data from bulky datasets and even combine
multiple data sets together.
6. It has the functionality to find and fill missing data.
7. Reshaping and pivoting of data sets into different forms.
8. Label-based slicing, indexing and subsetting of large data sets.
9. It allows us to apply operations to independent groups within the data.
10. It supports advanced time-series functionality( which is the use of a model
to predict future values based on previously observed values.
11. It supports visualization by integrating libraries such as matplotlib, ans
seaborn etc. Pandas is best at handling hugs tabular datasets comprising
different data formats.
Data Structures in Pandas
A data structure is a way of storing and organizing data in a computer so that it can be
accessed and worked with in an appropriate way.
Important data structures of pandas are–Series,DataFrame, Panel
1. Series
Series is like a one-dimensional array like structure with homogeneous data. For example,
the following series is a collection of integers.
Basic feature of series are
 Homogeneous data
 Size Immutable
 Values of Data Mutable
Pandas Series
It is like one-dimensional array capable of holding data of any type (integer, string, float, python objects,
etc.). Series can be created using Series() method. Any list or dictionary data can be converted into series
using this method.
A series can be described as an ordered dictionary with mapping of index values to data values.
Create an Empty Series
s1--------
series variable
pd-------
alternate name given to Pandas module
import pandas as pd
s1 = pd.Series()
print(s1)
Output
Series([], dtype: float64)
Creating Series using Series() with arguments
Syntax :- pandas.Series( data, index, dtype, copy)
Data supplied to Series() can be
 A sequence( list)
 An ndarray
 A scalar value
 A python dictionary
 A mathematical expression or function
Creating Series using List
Like array, a list is also a one-dimensional datatype. But the difference lies in the fact that an array contains elements of
same datatype, while a list may contain elements of same or different data types.
Syntax :- pandas.Series( data, index = idx)
import pandas as pd
s1=pd.Series([10,20,30,40,50])
print(s1)
*Pandas create a default index and automatically assigns the index value from 0 to 4, which is length of the list-1
import pandas as pd
s1=pd.Series([10,20,30,40])
s1.index=['a', 'b', 'c', 'd']
print(s1)
(or)
import pandas as pd
s1=pd.Series([10,20,30,40], index= ['a', 'b', 'c', 'd'])
print(s1)
Creating Series using nd array
import pandas as pd
s1=pd.Series([1,2,3.3,4,7])
print(s1)
* One of the element in the list, is a float value, it will convert the rest of the integer values into float and displays a
float series.
range() method
import pandas as pd
s1=pd.Series(range(4))
print(s1)
Access single and multiple values based on index.
import pandas as pd
s1=pd.Series([2,3,5.3,7,9], index=['first','sec','third','fourth','fifth'])
print(s1['sec'])
Output
3.0
import pandas as pd
s1=pd.Series([2,3,5.3,7,9], index=['first','sec','third','fourth','fifth'])
print(s1)
print(s1[['sec','third','fifth']])
Values and index
import pandas as pd
s1=pd.Series([10,20,30,40,50],index=['First', 'sec', 'third', 'forth', 'fifth'])
print(s1.values)
import pandas as pd
s1=pd.Series([10,20,30,40,50],index=['First', 'sec', 'third', 'forth','fifth'])
print(s1.index)
Accessing data from a Series with Position
Indexing, slicing and accessing data from a series
import pandas as pd
s1=pd.Series([1,2,3,4,5], index=['a', 'b', 'c', 'd', 'e'])
print(s1[0])
print(s1[:3])
print(s1[-3:])
iloc and loc
iloc – used for indexing or selecting based on position ie, by row number and column number. It refers to position-
based indexing.
Syntax
iloc = [<row number range>,<column number range>]
It refers to name-based
loc - used for indexing or selecting based on name ie, by row name and column name.
indexing.
Syntax
iloc = [<list of row names >,<list of column names>]
import pandas as pd
s1=pd.Series([1,2,3,4,5], index=['a', 'b', 'c', 'd', 'e'])
print(s1.iloc[1:4])
print(s1.loc['b':'e'])
Retrieving values from Series using head()and tail () functions
Series.head() function in a series fetches first ‘n’ values from a pandas object. By default, it gives us the top 5 rows of data
in the series. Series.tail() function displays the last 5 elements by default.
import pandas as pd
s1=pd.Series([10,20,30,40,50,60,70,80,90])
print(s1.head())
import pandas as pd
s1=pd.Series([10,20,30,40,50,60,70,80,90])
print(s1.head(3))
import pandas as pd
s1=pd.Series([10,20,30,40,50,60,70,80,90])
print(s1.tail(2))
Creating a Series from Scalar or Constant Values
A data is a scalar value for which it is a must to provide an index. This constant value shall be repeated to match the
length of the index.
import pandas as pd
s1=pd.Series(55, index=['a', 'b', 'c', 'd', 'e'])
print(s1)
Note :- here 55 is repeated for 5 times (as per no of index)
import pandas as pd
s1=pd.Series(55, index=[1,2,3,4,5])
print(s1)
Using range() method
import pandas as pd
s1=pd.Series(40, index=range(0,4))
print(s1)
import pandas as pd
s1=pd.Series(40, index=range(1,6,2))
print(s1)
Creating a Series with index of String (text) type
String or text can be used as an index to the elements of a series.
import pandas as pd
s1=pd.Series('Stay Home', index=['Madhav', 'Smitha', 'Vivek'])
print(s1)
Creating a Series with range() and for loop
import pandas as pd
s1=pd.Series(range(1,15,3), index=[x for x in 'abcde'])
print(s1)
Creating a Series using two different lists
* Two lists are passed as arguments to Series()method
import pandas as pd
months=['jan', 'feb', 'mar', 'apr', 'may']
no_days=[31,28,31,30,31]
s1=pd.Series(no_days,index=months)
print(s1)
Creating a Series using missing values [NaN]
We may need to create a series object for which size is defined but some element or data are missing. This is handled
by defining NaN [Not a Number], which is an attribute of Numpy library, defining a missing value using np.NaN.
import pandas as pd
import numpy as np
s1=pd.Series([31,28,31,np.NaN,31])
print(s1)
Creating Series from Dictionary
Using dictionary for creating a series gives us the advantage of built-in keys used as index. We do not require declaring
an index as a separate list: instead, built-in keys will be treated as the index
import pandas as pd
data = {'a' : 0., 'b' : 1., 'c' : 2.}
s = pd.Series(data)
print(s)
* A dictionary can be passed as input and if no index is specified, the dictionary keys are taken in the
sorted order to construct index
import pandas as pd1
data = {'a' : 0., 'b' : 1., 'c' : 2.}
s = pd1.Series(data,index=['b','c','d','a'])
print(s)
import pandas as pd
s1=pd.Series({'Jan':31,'Feb':28,'Mar':31,'Apr':30})
print(s1)
Naming a series
We can give a name to the two columns, index and values of a series using ‘name’ property.
import pandas as pd
s=pd.Series({'Jan':31,'Feb':28,'Mar':31,'Apr':30})
#naming the series and index
s.name='Days'
s.index.name='Month'
print(s)
* The index column is assigned the name ‘Month’ and data is assigned the name ‘Days’
Creating a Series using a mathematical expression/function
import pandas as pd
import numpy as np
s1=np.arange(5,10)
print(s1)
s2=pd.Series(index=s1,data=s1*4)
print(s2)
import pandas as pd
import numpy as np
s1=np.arange(5,10)
print(s1)
s2=pd.Series(index=s1,data=s1**4)
print(s2)
Mathematical operation on series
import pandas as pd
s1=pd.Series([10,20,30,40,50], index=[1,2,3,4,5])
print(s1)
s2=pd.Series([15,25,35,45,55], index=[1,2,3,4,5])
print(s2)
s3=pd.Series([11,22,33,44,55], index=[10,20,30,40,50])
print(s3)
print(s1+s2)
print(s1*s2)
print(s2/s1)
print(s1+s3)
Vector operations on series
Series supports vectors operations. Any operation to be performed on a series
gets performed on every single element of it.
import pandas as pd
s1=pd.Series([10,20,30,40,50], index=[1,2,3,4,5])
print(s1>25) # returns booleanoutput
import pandas as pd
s1=pd.Series([10,20,30,40,50], index=[1,2,3,4,5])
print(s1[s1>25]) # print s1 only if the value of s1 is greater than 25
Modifying Elements of a Series Object
import pandas as pd
s1=pd.Series([10,20,30,40,50], index=[1,2,3,4,5])
s2=pd.Series([15,25,35,45,55], index=[1,2,3,4,5])
s1[2]=222
s2[1:4]=[1000,2000,3000]
print(s1)
print(s2)
Deleting elements from a Series
We can delete an element from a series using drop() method by passing
the index of the element to be deleted as the argument to it.
import pandas as pd
s1=pd.Series([10,20,30,40,50], index=[1,2,3,4,5])
print(s1.drop(3))
import pandas as pd
s1=pd.Series([10,20,30,40,50], index=[1,2,3,4,5])
s2=pd.Series([[15,25,34],[35,45,55]])
print(s1)
print(s2)
print(s1.dtype)
print(s2.dtype)
print(type(s1))
print(type(s2))
print(s1.shape)
print(s2.shape)
print(s1.ndim, ' ', s2.ndim)
print(s1.size,'; ',s2.size)
print(s1.empty)
print(s2.hasnans)
print(s2.count())
print(s1.nbytes,';',s2.nbytes)
Series Object Attributes
Attributes Description
Series.index Returns index of the series
Series.values Returns ndarrays
Series.dtype Returns dtype object of the underlying data
Series.shape Returns tuple of the shape of underlying data
Series.size Returns the size of the element
Series.itemsize Returns the size of the dtype
Series.hasnans Returns true if there are any NaN
Series.empty Returns true if series object is empty

More Related Content

Similar to Python Library-Series.pptx

Python Pandas
Python PandasPython Pandas
Python Pandas
Sunil OS
 
pandasppt with informative topics coverage.pptx
pandasppt with informative topics coverage.pptxpandasppt with informative topics coverage.pptx
pandasppt with informative topics coverage.pptx
vallarasu200364
 
Unit 3_Numpy_Vsp.pptx
Unit 3_Numpy_Vsp.pptxUnit 3_Numpy_Vsp.pptx
Unit 3_Numpy_Vsp.pptx
prakashvs7
 
Introducing Pandas Objects.pptx
Introducing Pandas Objects.pptxIntroducing Pandas Objects.pptx
Introducing Pandas Objects.pptx
ssuser52a19e
 
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
AdityavardhanSingh15
 
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
lekha572836
 
DataFrame Creation.pptx
DataFrame Creation.pptxDataFrame Creation.pptx
DataFrame Creation.pptx
SarveshMariappan
 
XII - 2022-23 - IP - RAIPUR (CBSE FINAL EXAM).pdf
XII -  2022-23 - IP - RAIPUR (CBSE FINAL EXAM).pdfXII -  2022-23 - IP - RAIPUR (CBSE FINAL EXAM).pdf
XII - 2022-23 - IP - RAIPUR (CBSE FINAL EXAM).pdf
KrishnaJyotish1
 
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
 
Pandas Dataframe reading data Kirti final.pptx
Pandas Dataframe reading data  Kirti final.pptxPandas Dataframe reading data  Kirti final.pptx
Pandas Dataframe reading data Kirti final.pptx
Kirti Verma
 
Python-for-Data-Analysis.pptx
Python-for-Data-Analysis.pptxPython-for-Data-Analysis.pptx
Python-for-Data-Analysis.pptx
ParveenShaik21
 
Pandas.pptx
Pandas.pptxPandas.pptx
Pandas.pptx
Govardhan Bhavani
 
pandas-221217084954-937bb582.pdf
pandas-221217084954-937bb582.pdfpandas-221217084954-937bb582.pdf
pandas-221217084954-937bb582.pdf
scorsam1
 
Pandas Series
Pandas SeriesPandas Series
Pandas Series
Sangita Panchal
 
Lecture 3 intro2data
Lecture 3 intro2dataLecture 3 intro2data
Lecture 3 intro2data
Johnson Ubah
 
pandas dataframe notes.pdf
pandas dataframe notes.pdfpandas dataframe notes.pdf
pandas dataframe notes.pdf
AjeshSurejan2
 
Unit 4_Working with Graphs _python (2).pptx
Unit 4_Working with Graphs _python (2).pptxUnit 4_Working with Graphs _python (2).pptx
Unit 4_Working with Graphs _python (2).pptx
prakashvs7
 
Presentation on Pandas in _ detail .pptx
Presentation on Pandas in _ detail .pptxPresentation on Pandas in _ detail .pptx
Presentation on Pandas in _ detail .pptx
16115yogendraSingh
 
Pandas pythonfordatascience
Pandas pythonfordatasciencePandas pythonfordatascience
Pandas pythonfordatascience
Nishant Upadhyay
 

Similar to Python Library-Series.pptx (20)

Python Pandas
Python PandasPython Pandas
Python Pandas
 
pandasppt with informative topics coverage.pptx
pandasppt with informative topics coverage.pptxpandasppt with informative topics coverage.pptx
pandasppt with informative topics coverage.pptx
 
Unit 3_Numpy_Vsp.pptx
Unit 3_Numpy_Vsp.pptxUnit 3_Numpy_Vsp.pptx
Unit 3_Numpy_Vsp.pptx
 
Introducing Pandas Objects.pptx
Introducing Pandas Objects.pptxIntroducing Pandas Objects.pptx
Introducing Pandas Objects.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
 
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
 
DataFrame Creation.pptx
DataFrame Creation.pptxDataFrame Creation.pptx
DataFrame Creation.pptx
 
XII - 2022-23 - IP - RAIPUR (CBSE FINAL EXAM).pdf
XII -  2022-23 - IP - RAIPUR (CBSE FINAL EXAM).pdfXII -  2022-23 - IP - RAIPUR (CBSE FINAL EXAM).pdf
XII - 2022-23 - IP - RAIPUR (CBSE FINAL EXAM).pdf
 
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
 
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
 
Python-for-Data-Analysis.pptx
Python-for-Data-Analysis.pptxPython-for-Data-Analysis.pptx
Python-for-Data-Analysis.pptx
 
Pandas.pptx
Pandas.pptxPandas.pptx
Pandas.pptx
 
pandas-221217084954-937bb582.pdf
pandas-221217084954-937bb582.pdfpandas-221217084954-937bb582.pdf
pandas-221217084954-937bb582.pdf
 
Pandas Series
Pandas SeriesPandas Series
Pandas Series
 
ppanda.pptx
ppanda.pptxppanda.pptx
ppanda.pptx
 
Lecture 3 intro2data
Lecture 3 intro2dataLecture 3 intro2data
Lecture 3 intro2data
 
pandas dataframe notes.pdf
pandas dataframe notes.pdfpandas dataframe notes.pdf
pandas dataframe notes.pdf
 
Unit 4_Working with Graphs _python (2).pptx
Unit 4_Working with Graphs _python (2).pptxUnit 4_Working with Graphs _python (2).pptx
Unit 4_Working with Graphs _python (2).pptx
 
Presentation on Pandas in _ detail .pptx
Presentation on Pandas in _ detail .pptxPresentation on Pandas in _ detail .pptx
Presentation on Pandas in _ detail .pptx
 
Pandas pythonfordatascience
Pandas pythonfordatasciencePandas pythonfordatascience
Pandas pythonfordatascience
 

Recently uploaded

Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
Pixlogix Infotech
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 

Recently uploaded (20)

Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 

Python Library-Series.pptx

  • 1. Python Library – Pandas It is a most famous Python package for data science, which offers powerful and flexible data structures that make data analysis and manipulation easy. Pandas make data importing and data analyzing much easier. Pandas build on packages like NumPy and matplotlib to give us a single & convenient place for data analysis and visualization work. Pandas is a high level data manipulation tool developed by Wes McKinney.
  • 3. Basic Features of Panda 1. With a pandas dataframe, we can have different data types (float, int, string, datetime, etc) all in one place 2. Columns from a Panda data structure can be deleted or inserted 3. Good IO capabilities; Easily pull data from a MySQL database directly into a data frame 4. Itsupportsgroupbyoperationfordataaggregationandtransformationandalowshigh performancemergingandjoiningofdata. 5. It can easily select subsets of data from bulky datasets and even combine multiple data sets together. 6. It has the functionality to find and fill missing data. 7. Reshaping and pivoting of data sets into different forms. 8. Label-based slicing, indexing and subsetting of large data sets. 9. It allows us to apply operations to independent groups within the data. 10. It supports advanced time-series functionality( which is the use of a model to predict future values based on previously observed values. 11. It supports visualization by integrating libraries such as matplotlib, ans seaborn etc. Pandas is best at handling hugs tabular datasets comprising different data formats.
  • 4. Data Structures in Pandas A data structure is a way of storing and organizing data in a computer so that it can be accessed and worked with in an appropriate way. Important data structures of pandas are–Series,DataFrame, Panel 1. Series Series is like a one-dimensional array like structure with homogeneous data. For example, the following series is a collection of integers. Basic feature of series are  Homogeneous data  Size Immutable  Values of Data Mutable
  • 5. Pandas Series It is like one-dimensional array capable of holding data of any type (integer, string, float, python objects, etc.). Series can be created using Series() method. Any list or dictionary data can be converted into series using this method. A series can be described as an ordered dictionary with mapping of index values to data values. Create an Empty Series s1-------- series variable pd------- alternate name given to Pandas module import pandas as pd s1 = pd.Series() print(s1) Output Series([], dtype: float64) Creating Series using Series() with arguments Syntax :- pandas.Series( data, index, dtype, copy) Data supplied to Series() can be  A sequence( list)  An ndarray  A scalar value  A python dictionary  A mathematical expression or function
  • 6. Creating Series using List Like array, a list is also a one-dimensional datatype. But the difference lies in the fact that an array contains elements of same datatype, while a list may contain elements of same or different data types. Syntax :- pandas.Series( data, index = idx) import pandas as pd s1=pd.Series([10,20,30,40,50]) print(s1) *Pandas create a default index and automatically assigns the index value from 0 to 4, which is length of the list-1 import pandas as pd s1=pd.Series([10,20,30,40]) s1.index=['a', 'b', 'c', 'd'] print(s1) (or) import pandas as pd s1=pd.Series([10,20,30,40], index= ['a', 'b', 'c', 'd']) print(s1)
  • 7.
  • 8.
  • 9.
  • 11. import pandas as pd s1=pd.Series([1,2,3.3,4,7]) print(s1) * One of the element in the list, is a float value, it will convert the rest of the integer values into float and displays a float series. range() method import pandas as pd s1=pd.Series(range(4)) print(s1) Access single and multiple values based on index. import pandas as pd s1=pd.Series([2,3,5.3,7,9], index=['first','sec','third','fourth','fifth']) print(s1['sec']) Output 3.0 import pandas as pd s1=pd.Series([2,3,5.3,7,9], index=['first','sec','third','fourth','fifth']) print(s1) print(s1[['sec','third','fifth']])
  • 12. Values and index import pandas as pd s1=pd.Series([10,20,30,40,50],index=['First', 'sec', 'third', 'forth', 'fifth']) print(s1.values) import pandas as pd s1=pd.Series([10,20,30,40,50],index=['First', 'sec', 'third', 'forth','fifth']) print(s1.index) Accessing data from a Series with Position Indexing, slicing and accessing data from a series import pandas as pd s1=pd.Series([1,2,3,4,5], index=['a', 'b', 'c', 'd', 'e']) print(s1[0]) print(s1[:3]) print(s1[-3:])
  • 13. iloc and loc iloc – used for indexing or selecting based on position ie, by row number and column number. It refers to position- based indexing. Syntax iloc = [<row number range>,<column number range>] It refers to name-based loc - used for indexing or selecting based on name ie, by row name and column name. indexing. Syntax iloc = [<list of row names >,<list of column names>] import pandas as pd s1=pd.Series([1,2,3,4,5], index=['a', 'b', 'c', 'd', 'e']) print(s1.iloc[1:4]) print(s1.loc['b':'e'])
  • 14. Retrieving values from Series using head()and tail () functions Series.head() function in a series fetches first ‘n’ values from a pandas object. By default, it gives us the top 5 rows of data in the series. Series.tail() function displays the last 5 elements by default. import pandas as pd s1=pd.Series([10,20,30,40,50,60,70,80,90]) print(s1.head()) import pandas as pd s1=pd.Series([10,20,30,40,50,60,70,80,90]) print(s1.head(3)) import pandas as pd s1=pd.Series([10,20,30,40,50,60,70,80,90]) print(s1.tail(2)) Creating a Series from Scalar or Constant Values A data is a scalar value for which it is a must to provide an index. This constant value shall be repeated to match the length of the index. import pandas as pd s1=pd.Series(55, index=['a', 'b', 'c', 'd', 'e']) print(s1) Note :- here 55 is repeated for 5 times (as per no of index)
  • 15. import pandas as pd s1=pd.Series(55, index=[1,2,3,4,5]) print(s1) Using range() method import pandas as pd s1=pd.Series(40, index=range(0,4)) print(s1) import pandas as pd s1=pd.Series(40, index=range(1,6,2)) print(s1) Creating a Series with index of String (text) type String or text can be used as an index to the elements of a series. import pandas as pd s1=pd.Series('Stay Home', index=['Madhav', 'Smitha', 'Vivek']) print(s1)
  • 16. Creating a Series with range() and for loop import pandas as pd s1=pd.Series(range(1,15,3), index=[x for x in 'abcde']) print(s1) Creating a Series using two different lists * Two lists are passed as arguments to Series()method import pandas as pd months=['jan', 'feb', 'mar', 'apr', 'may'] no_days=[31,28,31,30,31] s1=pd.Series(no_days,index=months) print(s1) Creating a Series using missing values [NaN] We may need to create a series object for which size is defined but some element or data are missing. This is handled by defining NaN [Not a Number], which is an attribute of Numpy library, defining a missing value using np.NaN. import pandas as pd import numpy as np s1=pd.Series([31,28,31,np.NaN,31]) print(s1)
  • 17. Creating Series from Dictionary Using dictionary for creating a series gives us the advantage of built-in keys used as index. We do not require declaring an index as a separate list: instead, built-in keys will be treated as the index import pandas as pd data = {'a' : 0., 'b' : 1., 'c' : 2.} s = pd.Series(data) print(s) * A dictionary can be passed as input and if no index is specified, the dictionary keys are taken in the sorted order to construct index import pandas as pd1 data = {'a' : 0., 'b' : 1., 'c' : 2.} s = pd1.Series(data,index=['b','c','d','a']) print(s) import pandas as pd s1=pd.Series({'Jan':31,'Feb':28,'Mar':31,'Apr':30}) print(s1)
  • 18. Naming a series We can give a name to the two columns, index and values of a series using ‘name’ property. import pandas as pd s=pd.Series({'Jan':31,'Feb':28,'Mar':31,'Apr':30}) #naming the series and index s.name='Days' s.index.name='Month' print(s) * The index column is assigned the name ‘Month’ and data is assigned the name ‘Days’ Creating a Series using a mathematical expression/function import pandas as pd import numpy as np s1=np.arange(5,10) print(s1) s2=pd.Series(index=s1,data=s1*4) print(s2)
  • 19. import pandas as pd import numpy as np s1=np.arange(5,10) print(s1) s2=pd.Series(index=s1,data=s1**4) print(s2) Mathematical operation on series import pandas as pd s1=pd.Series([10,20,30,40,50], index=[1,2,3,4,5]) print(s1) s2=pd.Series([15,25,35,45,55], index=[1,2,3,4,5]) print(s2) s3=pd.Series([11,22,33,44,55], index=[10,20,30,40,50]) print(s3) print(s1+s2) print(s1*s2) print(s2/s1) print(s1+s3)
  • 20. Vector operations on series Series supports vectors operations. Any operation to be performed on a series gets performed on every single element of it. import pandas as pd s1=pd.Series([10,20,30,40,50], index=[1,2,3,4,5]) print(s1>25) # returns booleanoutput import pandas as pd s1=pd.Series([10,20,30,40,50], index=[1,2,3,4,5]) print(s1[s1>25]) # print s1 only if the value of s1 is greater than 25 Modifying Elements of a Series Object import pandas as pd s1=pd.Series([10,20,30,40,50], index=[1,2,3,4,5]) s2=pd.Series([15,25,35,45,55], index=[1,2,3,4,5]) s1[2]=222 s2[1:4]=[1000,2000,3000] print(s1) print(s2)
  • 21. Deleting elements from a Series We can delete an element from a series using drop() method by passing the index of the element to be deleted as the argument to it. import pandas as pd s1=pd.Series([10,20,30,40,50], index=[1,2,3,4,5]) print(s1.drop(3)) import pandas as pd s1=pd.Series([10,20,30,40,50], index=[1,2,3,4,5]) s2=pd.Series([[15,25,34],[35,45,55]]) print(s1) print(s2) print(s1.dtype) print(s2.dtype) print(type(s1)) print(type(s2)) print(s1.shape) print(s2.shape) print(s1.ndim, ' ', s2.ndim) print(s1.size,'; ',s2.size) print(s1.empty) print(s2.hasnans) print(s2.count()) print(s1.nbytes,';',s2.nbytes)
  • 22. Series Object Attributes Attributes Description Series.index Returns index of the series Series.values Returns ndarrays Series.dtype Returns dtype object of the underlying data Series.shape Returns tuple of the shape of underlying data Series.size Returns the size of the element Series.itemsize Returns the size of the dtype Series.hasnans Returns true if there are any NaN Series.empty Returns true if series object is empty