SlideShare une entreprise Scribd logo
1  sur  20
Télécharger pour lire hors ligne
Pandas
Introduction to pandas
Pandas is an open source python library providing high performance data
manipulation and analysis tool using its powerful data structure .Pandas is the
backbone for most of the data projects.
Through pandas , you get acquainted with your data by cleaning,transforming
and analyzing it.Python with pandas is used in a wide range of fields including
academic and commercial domains including
finance,economics,Statistics,analytics,etc.
Pandas package
You need to import the library module
pip install pandas
Import pandas as pd
Here, pd is referred to as an alias to the Pandas. However, it is not necessary to
import the library using alias, it just helps in writing less amount of code every
time a method or property is called.
Pandas generally provide two data structure for manipulating data, They are:
1)Series
2)DataFrame
Pandas Series
Pandas Series
Pandas Series is a one-dimensional labeled array capable of holding data of any
type (integer, string, float, python datatypes, etc.). The axis labels are collectively
called index. Pandas Series is nothing but a column in an excel sheet.
Creating a series from array
In order to create a series from array, we have to import a numpy module and
have to use array() function.
import pandas as pd
import numpy as np
# simple array
data = np.array(['p','y','t','h','o','n'])
ser = pd.Series(data)
print(ser)
Creating a series from list
In order to create a series from list, we have to first create a list after that we can
create a series from list.
import pandas as pd
# a simple list
list = ['p', 'y', 't', 'h', ‘o', 'n']
# create series form a list
ser = pd.Series(list)
print(ser)
Creating a series from dictionary
# import the pandas lib as pd
import pandas as pd
# create a dictionary
dictionary = {'A' : 10, 'B' : 20, 'C' : 30}
# create a series
series = pd.Series(dictionary)
print(series)
Accessing elements from series with position
# import pandas and numpy
import pandas as pd
import numpy as np
# creating simple array
data = np.array(['p','y','t','h','o','n', 'p','r','o','g','r','a','m'])
ser = pd.Series(data)
#retrieve the first five elements
print(ser[:5])
Accessing Element Using Label (index)
# import pandas and numpy
import pandas as pd
import numpy as np
# creating simple array
data = np.array(['p','y','t','h','o','n'])
ser = pd.Series( data, index=[10,11,12,13,14,15])
print(ser)
# accessing a element using index element
print(ser[12])
To find maximum value
import pandas as pd
# Creating the Series
sr = pd.Series([10, 25, 3, 25, 24, 6],index=['Coca Cola', 'Sprite', 'Coke', 'Fanta',
'Dew', ‘ThumbsUp‘])
# Print the series
print(sr)
#maximum value
result=max(sr)
print(result)
Pandas data frame
Data frame
Pandas DataFrame is two-dimensional size-mutable, potentially heterogeneous
tabular data structure with labeled axes (rows and columns). A Data frame is a
two-dimensional data structure, i.e., data is aligned in a tabular fashion in rows
and columns.
Creating a data frame using List
import pandas as pd
# list of strings
lst = ['data', 'visualization', 'using', 'python',
'and', 'r', 'programming']
# converting list into data frame
df = pd.DataFrame(lst)
print(df)
Creating a dataframe from dictionary
import pandas as pd
# intialise data of lists.
data = {'Name':['Tom', 'nick', ‘krish', 'jack'],
'Age':[20, 21, 19, 18]}
# Create DataFrame
df = pd.DataFrame(data)
# Print the output.
print(df)
Column selection
import pandas as pd
# Define a dictionary containing employee data
data = {'Name':['Jai‘, ‘Princi', 'Gaurav', ‘Anuj'],
'Age':[27, 24, 22, 32],
'Address':['Delhi', 'Kanpur', 'Allahabad', ‘Kannauj'],
'Qualification':[‘Msc', 'MA', 'MCA', ‘Phd']}
# Convert the dictionary into DataFrame
df = pd.DataFrame(data)
print(df)
# select two columns
print(df[['Name', 'Qualification']])
Working with missing data
# importing pandas as pd
import pandas as pd
# dictionary of lists
dict = {'First Score':[100, 90, np.nan, 95],
'Second Score': [30, 45, 56, np.nan],
'Third Score':[np.nan, 40, 80, 98]}
# creating a dataframe from list
df = pd.DataFrame(dict)
print(df)
# using isnull() function
df.isnull()
Filling missing values
In order to fill null values in the data sets we can use fillna() function
import pandas as pd
import numpy as np
dict = {'First Score':[100, 90, np.nan, 95],
'Second Score': [30, 45, 56, np.nan],
'Third Score':[np.nan, 40, 80, 98]}
df = pd.DataFrame(dict)
df.fillna(0)

Contenu connexe

Similaire à ACFrOgDHQC5OjIl5Q9jxVubx7Sot2XrlBki_kWu7QeD_CcOBLjkoUqIWzF_pIdWB9F91KupVVJdfRHEOHBF03mcm2hOQdV2b9fbqjReLZ5O3WmoYg18c8AOi-6A-Y8P4FpfdEBlifXh_7_xm5NRj.pdf

Python Pandas
Python PandasPython Pandas
Python PandasSunil OS
 
Introducing Pandas Objects.pptx
Introducing Pandas Objects.pptxIntroducing Pandas Objects.pptx
Introducing Pandas Objects.pptxssuser52a19e
 
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.pptxSumitMajukar
 
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
 
Presentation on Pandas in _ detail .pptx
Presentation on Pandas in _ detail .pptxPresentation on Pandas in _ detail .pptx
Presentation on Pandas in _ detail .pptx16115yogendraSingh
 
Unit 3_Numpy_Vsp.pptx
Unit 3_Numpy_Vsp.pptxUnit 3_Numpy_Vsp.pptx
Unit 3_Numpy_Vsp.pptxprakashvs7
 
PYTHON PANDAS.pptx
PYTHON PANDAS.pptxPYTHON PANDAS.pptx
PYTHON PANDAS.pptxXICSStudents
 
Pandas pythonfordatascience
Pandas pythonfordatasciencePandas pythonfordatascience
Pandas pythonfordatascienceNishant Upadhyay
 
pandasppt with informative topics coverage.pptx
pandasppt with informative topics coverage.pptxpandasppt with informative topics coverage.pptx
pandasppt with informative topics coverage.pptxvallarasu200364
 
Python Pandas for Data Science cheatsheet
Python Pandas for Data Science cheatsheet Python Pandas for Data Science cheatsheet
Python Pandas for Data Science cheatsheet Dr. Volkan OBAN
 
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).pdfKrishnaJyotish1
 
pandas dataframe notes.pdf
pandas dataframe notes.pdfpandas dataframe notes.pdf
pandas dataframe notes.pdfAjeshSurejan2
 
pandas-221217084954-937bb582.pdf
pandas-221217084954-937bb582.pdfpandas-221217084954-937bb582.pdf
pandas-221217084954-937bb582.pdfscorsam1
 
Introduction to pandas
Introduction to pandasIntroduction to pandas
Introduction to pandasPiyush rai
 
Comparing EDA with classical and Bayesian analysis.pptx
Comparing EDA with classical and Bayesian analysis.pptxComparing EDA with classical and Bayesian analysis.pptx
Comparing EDA with classical and Bayesian analysis.pptxPremaGanesh1
 

Similaire à ACFrOgDHQC5OjIl5Q9jxVubx7Sot2XrlBki_kWu7QeD_CcOBLjkoUqIWzF_pIdWB9F91KupVVJdfRHEOHBF03mcm2hOQdV2b9fbqjReLZ5O3WmoYg18c8AOi-6A-Y8P4FpfdEBlifXh_7_xm5NRj.pdf (20)

Python Pandas
Python PandasPython Pandas
Python Pandas
 
Introducing Pandas Objects.pptx
Introducing Pandas Objects.pptxIntroducing Pandas Objects.pptx
Introducing Pandas Objects.pptx
 
pandas directories on the python language.pptx
pandas directories on the python language.pptxpandas directories on the python language.pptx
pandas directories on the python language.pptx
 
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
 
Presentation on Pandas in _ detail .pptx
Presentation on Pandas in _ detail .pptxPresentation on Pandas in _ detail .pptx
Presentation on Pandas in _ detail .pptx
 
Unit 3_Numpy_Vsp.pptx
Unit 3_Numpy_Vsp.pptxUnit 3_Numpy_Vsp.pptx
Unit 3_Numpy_Vsp.pptx
 
PYTHON PANDAS.pptx
PYTHON PANDAS.pptxPYTHON PANDAS.pptx
PYTHON PANDAS.pptx
 
Pandas pythonfordatascience
Pandas pythonfordatasciencePandas pythonfordatascience
Pandas pythonfordatascience
 
ppanda.pptx
ppanda.pptxppanda.pptx
ppanda.pptx
 
phgv.pptx.pptx
phgv.pptx.pptxphgv.pptx.pptx
phgv.pptx.pptx
 
2 pandasbasic
2 pandasbasic2 pandasbasic
2 pandasbasic
 
pandasppt with informative topics coverage.pptx
pandasppt with informative topics coverage.pptxpandasppt with informative topics coverage.pptx
pandasppt with informative topics coverage.pptx
 
Python Pandas for Data Science cheatsheet
Python Pandas for Data Science cheatsheet Python Pandas for Data Science cheatsheet
Python Pandas for Data Science cheatsheet
 
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 dataframe notes.pdf
pandas dataframe notes.pdfpandas dataframe notes.pdf
pandas dataframe notes.pdf
 
Pandas.pptx
Pandas.pptxPandas.pptx
Pandas.pptx
 
pandas-221217084954-937bb582.pdf
pandas-221217084954-937bb582.pdfpandas-221217084954-937bb582.pdf
pandas-221217084954-937bb582.pdf
 
Introduction to pandas
Introduction to pandasIntroduction to pandas
Introduction to pandas
 
Comparing EDA with classical and Bayesian analysis.pptx
Comparing EDA with classical and Bayesian analysis.pptxComparing EDA with classical and Bayesian analysis.pptx
Comparing EDA with classical and Bayesian analysis.pptx
 

Plus de DineshThallapelly

D.Sai Tharun 20848 BCA 2nd year-converted.pptx
D.Sai Tharun 20848 BCA 2nd year-converted.pptxD.Sai Tharun 20848 BCA 2nd year-converted.pptx
D.Sai Tharun 20848 BCA 2nd year-converted.pptxDineshThallapelly
 
IMG_20230326_134431 (15 files merged).ppt
IMG_20230326_134431 (15 files merged).pptIMG_20230326_134431 (15 files merged).ppt
IMG_20230326_134431 (15 files merged).pptDineshThallapelly
 
IMG_20230325_121848 (13 files merged).ppt
IMG_20230325_121848 (13 files merged).pptIMG_20230325_121848 (13 files merged).ppt
IMG_20230325_121848 (13 files merged).pptDineshThallapelly
 
newmicrosoftofficepowerpointpresentation-160805121228 (1).pdf
newmicrosoftofficepowerpointpresentation-160805121228 (1).pdfnewmicrosoftofficepowerpointpresentation-160805121228 (1).pdf
newmicrosoftofficepowerpointpresentation-160805121228 (1).pdfDineshThallapelly
 
1601-308-Wright Brothers.pptx
1601-308-Wright Brothers.pptx1601-308-Wright Brothers.pptx
1601-308-Wright Brothers.pptxDineshThallapelly
 
ACFrOgAabSLW3ZCRLJ0i-To_2fPk_pA9QThyDKNNlA3VK282MnXaLGJa7APKD15-TW9zT_QI98dAH...
ACFrOgAabSLW3ZCRLJ0i-To_2fPk_pA9QThyDKNNlA3VK282MnXaLGJa7APKD15-TW9zT_QI98dAH...ACFrOgAabSLW3ZCRLJ0i-To_2fPk_pA9QThyDKNNlA3VK282MnXaLGJa7APKD15-TW9zT_QI98dAH...
ACFrOgAabSLW3ZCRLJ0i-To_2fPk_pA9QThyDKNNlA3VK282MnXaLGJa7APKD15-TW9zT_QI98dAH...DineshThallapelly
 

Plus de DineshThallapelly (6)

D.Sai Tharun 20848 BCA 2nd year-converted.pptx
D.Sai Tharun 20848 BCA 2nd year-converted.pptxD.Sai Tharun 20848 BCA 2nd year-converted.pptx
D.Sai Tharun 20848 BCA 2nd year-converted.pptx
 
IMG_20230326_134431 (15 files merged).ppt
IMG_20230326_134431 (15 files merged).pptIMG_20230326_134431 (15 files merged).ppt
IMG_20230326_134431 (15 files merged).ppt
 
IMG_20230325_121848 (13 files merged).ppt
IMG_20230325_121848 (13 files merged).pptIMG_20230325_121848 (13 files merged).ppt
IMG_20230325_121848 (13 files merged).ppt
 
newmicrosoftofficepowerpointpresentation-160805121228 (1).pdf
newmicrosoftofficepowerpointpresentation-160805121228 (1).pdfnewmicrosoftofficepowerpointpresentation-160805121228 (1).pdf
newmicrosoftofficepowerpointpresentation-160805121228 (1).pdf
 
1601-308-Wright Brothers.pptx
1601-308-Wright Brothers.pptx1601-308-Wright Brothers.pptx
1601-308-Wright Brothers.pptx
 
ACFrOgAabSLW3ZCRLJ0i-To_2fPk_pA9QThyDKNNlA3VK282MnXaLGJa7APKD15-TW9zT_QI98dAH...
ACFrOgAabSLW3ZCRLJ0i-To_2fPk_pA9QThyDKNNlA3VK282MnXaLGJa7APKD15-TW9zT_QI98dAH...ACFrOgAabSLW3ZCRLJ0i-To_2fPk_pA9QThyDKNNlA3VK282MnXaLGJa7APKD15-TW9zT_QI98dAH...
ACFrOgAabSLW3ZCRLJ0i-To_2fPk_pA9QThyDKNNlA3VK282MnXaLGJa7APKD15-TW9zT_QI98dAH...
 

Dernier

Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...gajnagarg
 
Gartner's Data Analytics Maturity Model.pptx
Gartner's Data Analytics Maturity Model.pptxGartner's Data Analytics Maturity Model.pptx
Gartner's Data Analytics Maturity Model.pptxchadhar227
 
怎样办理纽约州立大学宾汉姆顿分校毕业证(SUNY-Bin毕业证书)成绩单学校原版复制
怎样办理纽约州立大学宾汉姆顿分校毕业证(SUNY-Bin毕业证书)成绩单学校原版复制怎样办理纽约州立大学宾汉姆顿分校毕业证(SUNY-Bin毕业证书)成绩单学校原版复制
怎样办理纽约州立大学宾汉姆顿分校毕业证(SUNY-Bin毕业证书)成绩单学校原版复制vexqp
 
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...nirzagarg
 
7. Epi of Chronic respiratory diseases.ppt
7. Epi of Chronic respiratory diseases.ppt7. Epi of Chronic respiratory diseases.ppt
7. Epi of Chronic respiratory diseases.pptibrahimabdi22
 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Researchmichael115558
 
Capstone in Interprofessional Informatic // IMPACT OF COVID 19 ON EDUCATION
Capstone in Interprofessional Informatic  // IMPACT OF COVID 19 ON EDUCATIONCapstone in Interprofessional Informatic  // IMPACT OF COVID 19 ON EDUCATION
Capstone in Interprofessional Informatic // IMPACT OF COVID 19 ON EDUCATIONLakpaYanziSherpa
 
Harnessing the Power of GenAI for BI and Reporting.pptx
Harnessing the Power of GenAI for BI and Reporting.pptxHarnessing the Power of GenAI for BI and Reporting.pptx
Harnessing the Power of GenAI for BI and Reporting.pptxParas Gupta
 
怎样办理旧金山城市学院毕业证(CCSF毕业证书)成绩单学校原版复制
怎样办理旧金山城市学院毕业证(CCSF毕业证书)成绩单学校原版复制怎样办理旧金山城市学院毕业证(CCSF毕业证书)成绩单学校原版复制
怎样办理旧金山城市学院毕业证(CCSF毕业证书)成绩单学校原版复制vexqp
 
Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...
Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...
Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...nirzagarg
 
怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制
怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制
怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制vexqp
 
怎样办理圣路易斯大学毕业证(SLU毕业证书)成绩单学校原版复制
怎样办理圣路易斯大学毕业证(SLU毕业证书)成绩单学校原版复制怎样办理圣路易斯大学毕业证(SLU毕业证书)成绩单学校原版复制
怎样办理圣路易斯大学毕业证(SLU毕业证书)成绩单学校原版复制vexqp
 
Jual Cytotec Asli Obat Aborsi No. 1 Paling Manjur
Jual Cytotec Asli Obat Aborsi No. 1 Paling ManjurJual Cytotec Asli Obat Aborsi No. 1 Paling Manjur
Jual Cytotec Asli Obat Aborsi No. 1 Paling Manjurptikerjasaptiker
 
Predicting HDB Resale Prices - Conducting Linear Regression Analysis With Orange
Predicting HDB Resale Prices - Conducting Linear Regression Analysis With OrangePredicting HDB Resale Prices - Conducting Linear Regression Analysis With Orange
Predicting HDB Resale Prices - Conducting Linear Regression Analysis With OrangeThinkInnovation
 
PLE-statistics document for primary schs
PLE-statistics document for primary schsPLE-statistics document for primary schs
PLE-statistics document for primary schscnajjemba
 
Data Analyst Tasks to do the internship.pdf
Data Analyst Tasks to do the internship.pdfData Analyst Tasks to do the internship.pdf
Data Analyst Tasks to do the internship.pdftheeltifs
 
Switzerland Constitution 2002.pdf.........
Switzerland Constitution 2002.pdf.........Switzerland Constitution 2002.pdf.........
Switzerland Constitution 2002.pdf.........EfruzAsilolu
 
一比一原版(UCD毕业证书)加州大学戴维斯分校毕业证成绩单原件一模一样
一比一原版(UCD毕业证书)加州大学戴维斯分校毕业证成绩单原件一模一样一比一原版(UCD毕业证书)加州大学戴维斯分校毕业证成绩单原件一模一样
一比一原版(UCD毕业证书)加州大学戴维斯分校毕业证成绩单原件一模一样wsppdmt
 
The-boAt-Story-Navigating-the-Waves-of-Innovation.pptx
The-boAt-Story-Navigating-the-Waves-of-Innovation.pptxThe-boAt-Story-Navigating-the-Waves-of-Innovation.pptx
The-boAt-Story-Navigating-the-Waves-of-Innovation.pptxVivek487417
 

Dernier (20)

Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...
 
Gartner's Data Analytics Maturity Model.pptx
Gartner's Data Analytics Maturity Model.pptxGartner's Data Analytics Maturity Model.pptx
Gartner's Data Analytics Maturity Model.pptx
 
怎样办理纽约州立大学宾汉姆顿分校毕业证(SUNY-Bin毕业证书)成绩单学校原版复制
怎样办理纽约州立大学宾汉姆顿分校毕业证(SUNY-Bin毕业证书)成绩单学校原版复制怎样办理纽约州立大学宾汉姆顿分校毕业证(SUNY-Bin毕业证书)成绩单学校原版复制
怎样办理纽约州立大学宾汉姆顿分校毕业证(SUNY-Bin毕业证书)成绩单学校原版复制
 
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Hapur [ 7014168258 ] Call Me For Genuine Models We ...
 
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get CytotecAbortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
 
7. Epi of Chronic respiratory diseases.ppt
7. Epi of Chronic respiratory diseases.ppt7. Epi of Chronic respiratory diseases.ppt
7. Epi of Chronic respiratory diseases.ppt
 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Research
 
Capstone in Interprofessional Informatic // IMPACT OF COVID 19 ON EDUCATION
Capstone in Interprofessional Informatic  // IMPACT OF COVID 19 ON EDUCATIONCapstone in Interprofessional Informatic  // IMPACT OF COVID 19 ON EDUCATION
Capstone in Interprofessional Informatic // IMPACT OF COVID 19 ON EDUCATION
 
Harnessing the Power of GenAI for BI and Reporting.pptx
Harnessing the Power of GenAI for BI and Reporting.pptxHarnessing the Power of GenAI for BI and Reporting.pptx
Harnessing the Power of GenAI for BI and Reporting.pptx
 
怎样办理旧金山城市学院毕业证(CCSF毕业证书)成绩单学校原版复制
怎样办理旧金山城市学院毕业证(CCSF毕业证书)成绩单学校原版复制怎样办理旧金山城市学院毕业证(CCSF毕业证书)成绩单学校原版复制
怎样办理旧金山城市学院毕业证(CCSF毕业证书)成绩单学校原版复制
 
Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...
Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...
Top profile Call Girls In Bihar Sharif [ 7014168258 ] Call Me For Genuine Mod...
 
怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制
怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制
怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制
 
怎样办理圣路易斯大学毕业证(SLU毕业证书)成绩单学校原版复制
怎样办理圣路易斯大学毕业证(SLU毕业证书)成绩单学校原版复制怎样办理圣路易斯大学毕业证(SLU毕业证书)成绩单学校原版复制
怎样办理圣路易斯大学毕业证(SLU毕业证书)成绩单学校原版复制
 
Jual Cytotec Asli Obat Aborsi No. 1 Paling Manjur
Jual Cytotec Asli Obat Aborsi No. 1 Paling ManjurJual Cytotec Asli Obat Aborsi No. 1 Paling Manjur
Jual Cytotec Asli Obat Aborsi No. 1 Paling Manjur
 
Predicting HDB Resale Prices - Conducting Linear Regression Analysis With Orange
Predicting HDB Resale Prices - Conducting Linear Regression Analysis With OrangePredicting HDB Resale Prices - Conducting Linear Regression Analysis With Orange
Predicting HDB Resale Prices - Conducting Linear Regression Analysis With Orange
 
PLE-statistics document for primary schs
PLE-statistics document for primary schsPLE-statistics document for primary schs
PLE-statistics document for primary schs
 
Data Analyst Tasks to do the internship.pdf
Data Analyst Tasks to do the internship.pdfData Analyst Tasks to do the internship.pdf
Data Analyst Tasks to do the internship.pdf
 
Switzerland Constitution 2002.pdf.........
Switzerland Constitution 2002.pdf.........Switzerland Constitution 2002.pdf.........
Switzerland Constitution 2002.pdf.........
 
一比一原版(UCD毕业证书)加州大学戴维斯分校毕业证成绩单原件一模一样
一比一原版(UCD毕业证书)加州大学戴维斯分校毕业证成绩单原件一模一样一比一原版(UCD毕业证书)加州大学戴维斯分校毕业证成绩单原件一模一样
一比一原版(UCD毕业证书)加州大学戴维斯分校毕业证成绩单原件一模一样
 
The-boAt-Story-Navigating-the-Waves-of-Innovation.pptx
The-boAt-Story-Navigating-the-Waves-of-Innovation.pptxThe-boAt-Story-Navigating-the-Waves-of-Innovation.pptx
The-boAt-Story-Navigating-the-Waves-of-Innovation.pptx
 

ACFrOgDHQC5OjIl5Q9jxVubx7Sot2XrlBki_kWu7QeD_CcOBLjkoUqIWzF_pIdWB9F91KupVVJdfRHEOHBF03mcm2hOQdV2b9fbqjReLZ5O3WmoYg18c8AOi-6A-Y8P4FpfdEBlifXh_7_xm5NRj.pdf

  • 2. Introduction to pandas Pandas is an open source python library providing high performance data manipulation and analysis tool using its powerful data structure .Pandas is the backbone for most of the data projects. Through pandas , you get acquainted with your data by cleaning,transforming and analyzing it.Python with pandas is used in a wide range of fields including academic and commercial domains including finance,economics,Statistics,analytics,etc.
  • 3. Pandas package You need to import the library module pip install pandas Import pandas as pd Here, pd is referred to as an alias to the Pandas. However, it is not necessary to import the library using alias, it just helps in writing less amount of code every time a method or property is called. Pandas generally provide two data structure for manipulating data, They are: 1)Series 2)DataFrame
  • 5. Pandas Series Pandas Series is a one-dimensional labeled array capable of holding data of any type (integer, string, float, python datatypes, etc.). The axis labels are collectively called index. Pandas Series is nothing but a column in an excel sheet.
  • 6. Creating a series from array In order to create a series from array, we have to import a numpy module and have to use array() function. import pandas as pd import numpy as np # simple array data = np.array(['p','y','t','h','o','n']) ser = pd.Series(data) print(ser)
  • 7. Creating a series from list In order to create a series from list, we have to first create a list after that we can create a series from list. import pandas as pd # a simple list list = ['p', 'y', 't', 'h', ‘o', 'n'] # create series form a list ser = pd.Series(list) print(ser)
  • 8. Creating a series from dictionary # import the pandas lib as pd import pandas as pd # create a dictionary dictionary = {'A' : 10, 'B' : 20, 'C' : 30} # create a series series = pd.Series(dictionary) print(series)
  • 9. Accessing elements from series with position # import pandas and numpy import pandas as pd import numpy as np # creating simple array data = np.array(['p','y','t','h','o','n', 'p','r','o','g','r','a','m']) ser = pd.Series(data) #retrieve the first five elements print(ser[:5])
  • 10. Accessing Element Using Label (index) # import pandas and numpy import pandas as pd import numpy as np # creating simple array data = np.array(['p','y','t','h','o','n']) ser = pd.Series( data, index=[10,11,12,13,14,15]) print(ser) # accessing a element using index element print(ser[12])
  • 11. To find maximum value import pandas as pd # Creating the Series sr = pd.Series([10, 25, 3, 25, 24, 6],index=['Coca Cola', 'Sprite', 'Coke', 'Fanta', 'Dew', ‘ThumbsUp‘]) # Print the series print(sr) #maximum value result=max(sr) print(result)
  • 12.
  • 14. Data frame Pandas DataFrame is two-dimensional size-mutable, potentially heterogeneous tabular data structure with labeled axes (rows and columns). A Data frame is a two-dimensional data structure, i.e., data is aligned in a tabular fashion in rows and columns.
  • 15. Creating a data frame using List import pandas as pd # list of strings lst = ['data', 'visualization', 'using', 'python', 'and', 'r', 'programming'] # converting list into data frame df = pd.DataFrame(lst) print(df)
  • 16. Creating a dataframe from dictionary import pandas as pd # intialise data of lists. data = {'Name':['Tom', 'nick', ‘krish', 'jack'], 'Age':[20, 21, 19, 18]} # Create DataFrame df = pd.DataFrame(data) # Print the output. print(df)
  • 17. Column selection import pandas as pd # Define a dictionary containing employee data data = {'Name':['Jai‘, ‘Princi', 'Gaurav', ‘Anuj'], 'Age':[27, 24, 22, 32], 'Address':['Delhi', 'Kanpur', 'Allahabad', ‘Kannauj'], 'Qualification':[‘Msc', 'MA', 'MCA', ‘Phd']} # Convert the dictionary into DataFrame df = pd.DataFrame(data) print(df) # select two columns print(df[['Name', 'Qualification']])
  • 18. Working with missing data # importing pandas as pd import pandas as pd # dictionary of lists dict = {'First Score':[100, 90, np.nan, 95], 'Second Score': [30, 45, 56, np.nan], 'Third Score':[np.nan, 40, 80, 98]} # creating a dataframe from list df = pd.DataFrame(dict) print(df)
  • 19. # using isnull() function df.isnull()
  • 20. Filling missing values In order to fill null values in the data sets we can use fillna() function import pandas as pd import numpy as np dict = {'First Score':[100, 90, np.nan, 95], 'Second Score': [30, 45, 56, np.nan], 'Third Score':[np.nan, 40, 80, 98]} df = pd.DataFrame(dict) df.fillna(0)