Topic 6 :Data Analysis and Visualisation
Learning Outcomes:
(a) Identify basic Pandas methods for data analysis (indexing, describe(), max(), min() and mean())
CP125
Topic 6 :Data Analysis and Visualisation
Table of Contents
CP125
Indexing
Ways to Indexing
Native Python Accessor
Column Selection Only
Pandas DataFrame Method
Column and Row Selection
Integer Based Indexing
Label based Indexing
Indexing Operator
Single and Multiple Column
Attribute accessor
Single Column Only
dot Operator
[ ] bracket Operator
loc[row_label,col_label]
iloc[row_indices,col_indices]
3a
3b & 3c
Recap :
4. Using iloc()- Using Index instead of label/header name
It allows you to select specific rows and columns from a DataFrame using their integer positions. The i stand for Integer index.
How does iloc work?
df.iloc[row_index,column_index]
4b.1 Selecting one row
To select a single row, passed the row index value.
eg: row 100
It return single record with index of 100
4b.2
Selecting
multiple rows
pass the row
start_index: end_index
to the iloc operator
eg: loc[10:100]
It return the record start from index of 10 until 99.
index 100 is exclusive
[10:100] return 90 rows
4c.1
Selecting
multiple rows
and specific columns
It return rows of index 10 until 100 exclusive and only columns 1 until 3.
column index | Column |
1 | SepalLengthCm |
2 | SepalWidthCm |
3 | PetalLengthCm |
4 | not included |
Basic Statistical Analysis
2. mean() # return average value of the selected columns
3. max() # return highest value in the selected columns
4. min() # return lowest value in the selected columns
Statistical analysis must only be applied to numerical columns
6. Describing
Dataframe
df.describe()
Return statistical
summary of all
numerical columns
7a
Max for
all
Species
df.max()
7b
Max
for
specific
Species
df.max()
8a
Min for
all Species
df.min()
8b
Min
for
specific
Species
df.min()
9a
Mean for
all
Species
df.mean()
9b Mean
for a
specific
Species
df.mean()