0% found this document useful (0 votes)
3 views

Python - Lesson 4

hoc python 4

Uploaded by

Mit Jiu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Python - Lesson 4

hoc python 4

Uploaded by

Mit Jiu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 26

PYTHON

Tutor: Nguyễn Lê Chí Bảo


01 03

Introduction to Python Numpy


MODULE

02 04
Function Pandas
MODULE 4.
PANDAS
Module 4: Pandas

Introduction to Pandas
Module 4: Pandas

Pandas Data types


Module 4: Pandas

Pandas Data types


Series DataFrame
index values index columns
A 6 foo Bar Baz
B 3.14 A X 6 True
C -4 B Y 10 True
D 0 C z NaN False
Module 4: Pandas

Series – Creation

Creation:
• S = pd.Series(data,
index=index_list)
• Data can be many different things:
+ Python dict
+ An np.array
+ List
Module 4: Pandas

Series - Creation
Import pandas as pd
s1 = pd.Series( [1, 2, 3, 4] )
s2 = pd.Series( [1, 2, 3, 4], index=[‘A’, ’B’, ’C’, ’D’])

s1 s2
0 1 A 1
1 2 B 2
2 3 C 3
3 4 D 4
Module 4: Pandas

Series is ndarray-like
Module 4: Pandas

Series is dict-like
A Series is like a fixed-size dict in that you can get and set values by index label
Module 4: Pandas

Series – Broadcasting, Filter


The Series class automatically broadcasts arithmetical operations by a scalar to all of the elements.
Module 4: Pandas

Series – Missing Data


Module 4: Pandas

Series - Computing Statistics


Module 4: Pandas

DataFrame - Creation
• DataFrame is a 2D labeled data structure with columns of potentially
different types.
• It accepts many different kinds of input:
+ Dict of 1D ndarrays, lists, dicts, or Series
+ 2-D numpy.ndarray
+ Structured or record ndarray
+ A Series
+ Another DataFrame
Module 4: Pandas

DataFrame - Creation

one two
a 1 1
b 2 2
c 3 3
d NaN 4
Module 4: Pandas

DataFrame – load file


Load from text file (i.e., cvs, txt, tsv, json, excel, .... )
Module 4: Pandas

DataFrame - extraction
The elementary extraction methods
Module 4: Pandas

DataFrame - extraction
Module 4: Pandas

DataFrame - Operators
Module 4: Pandas

DataFrame - Operators
Module 4: Pandas

DataFrame- Assigning new columns


The assign() method that allows you to easily create new columns that are potentially
derived from existing columns. (return a copy of data)
Module 4: Pandas

DataFrame - Statistics
The statistical functions such as: min(), max(), mean(), median(), sum(), cumsum(), var(), std()…
also work on DataFrame

Example: Correlation Matrix Of Values: df.corr()


Module 4: Pandas

DataFrame – Merge
Module 4: Pandas

DataFrame - Append
Module 4: Pandas

DataFrame - Grouping
THANKS
CREDITS: This presentation template was created by
Slidesgo, including icons by Flaticon, and Name: Nguyễn Lê Chí Bảo
infographics & images by Freepik and illustrations Email: [email protected]
by Storyset Phone: 091 544 2420
Linkedin: nguyenlechibao

You might also like