SlideShare a Scribd company logo
Dictionaries, Part 1
INTERMEDIATE PYTHON
Hugo Bowne-Anderson
Data Scientist at DataCamp
INTERMEDIATE PYTHON
List
pop = [30.55, 2.77, 39.21]
countries = ["afghanistan", "albania", "algeria"]
ind_alb = countries.index("albania")
ind_alb
1
pop[ind_alb]
2.77
Not convenient
Not intuitive
INTERMEDIATE PYTHON
Dictionary
pop = [30.55, 2.77, 39.21]
countries = ["afghanistan", "albania", "algeria"]
...
{ }
INTERMEDIATE PYTHON
Dictionary
pop = [30.55, 2.77, 39.21]
countries = ["afghanistan", "albania", "algeria"]
...
{"afghanistan":30.55, }
INTERMEDIATE PYTHON
Dictionary
pop = [30.55, 2.77, 39.21]
countries = ["afghanistan", "albania", "algeria"]
...
world = {"afghanistan":30.55, "albania":2.77, "algeria":39.21}
world["albania"]
2.77
Let's practice!
INTERMEDIATE PYTHON
Dictionaries, Part 2
INTERMEDIATE PYTHON
Hugo Bowne-Anderson
Data Scientist at DataCamp
INTERMEDIATE PYTHON
Recap
world = {"afghanistan":30.55, "albania":2.77, "algeria":39.21}
world["albania"]
2.77
world = {"afghanistan":30.55, "albania":2.77,
"algeria":39.21, "albania":2.81}
world
{'afghanistan': 30.55, 'albania': 2.81, 'algeria': 39.21}
INTERMEDIATE PYTHON
Recap
Keys have to be "immutable" objects
{0:"hello", True:"dear", "two":"world"}
{0: 'hello', True: 'dear', 'two': 'world'}
{["just", "to", "test"]: "value"}
TypeError: unhashable type: 'list'
INTERMEDIATE PYTHON
Principality of Sealand
Source: Wikipedia
1
INTERMEDIATE PYTHON
Dictionary
world["sealand"] = 0.000027
world
{'afghanistan': 30.55, 'albania': 2.81,
'algeria': 39.21, 'sealand': 2.7e-05}
"sealand" in world
True
INTERMEDIATE PYTHON
Dictionary
world["sealand"] = 0.000028
world
{'afghanistan': 30.55, 'albania': 2.81,
'algeria': 39.21, 'sealand': 2.8e-05}
del(world["sealand"])
world
{'afghanistan': 30.55, 'albania': 2.81, 'algeria': 39.21}
INTERMEDIATE PYTHON
List vs Dictionary
INTERMEDIATE PYTHON
List vs Dictionary
INTERMEDIATE PYTHON
List vs Dictionary
INTERMEDIATE PYTHON
List vs Dictionary
INTERMEDIATE PYTHON
List vs Dictionary
INTERMEDIATE PYTHON
List vs Dictionary
INTERMEDIATE PYTHON
List vs Dictionary
INTERMEDIATE PYTHON
List vs Dictionary
Let's practice!
INTERMEDIATE PYTHON
Pandas, Part 1
INTERMEDIATE PYTHON
Hugo Bowne-Anderson
Data Scientist at DataCamp
INTERMEDIATE PYTHON
Tabular dataset examples
INTERMEDIATE PYTHON
Tabular dataset examples
INTERMEDIATE PYTHON
Tabular dataset examples
INTERMEDIATE PYTHON
Datasets in Python
2D Numpy array?
One data type
INTERMEDIATE PYTHON
Datasets in Python
INTERMEDIATE PYTHON
Datasets in Python
pandas!
High level data manipulation tool
Wes McKinney
Built on Numpy
DataFrame
INTERMEDIATE PYTHON
DataFrame
brics
country capital area population
BR Brazil Brasilia 8.516 200.40
RU Russia Moscow 17.100 143.50
IN India New Delhi 3.286 1252.00
CH China Beijing 9.597 1357.00
SA South Africa Pretoria 1.221 52.98
INTERMEDIATE PYTHON
DataFrame from Dictionary
dict = {
"country":["Brazil", "Russia", "India", "China", "South Africa"],
"capital":["Brasilia", "Moscow", "New Delhi", "Beijing", "Pretoria"],
"area":[8.516, 17.10, 3.286, 9.597, 1.221]
"population":[200.4, 143.5, 1252, 1357, 52.98] }
keys (column labels)
values (data, column by column)
import pandas as pd
brics = pd.DataFrame(dict)
INTERMEDIATE PYTHON
DataFrame from Dictionary (2)
brics
area capital country population
0 8.516 Brasilia Brazil 200.40
1 17.100 Moscow Russia 143.50
2 3.286 New Delhi India 1252.00
3 9.597 Beijing China 1357.00
4 1.221 Pretoria South Africa 52.98
brics.index = ["BR", "RU", "IN", "CH", "SA"]
brics
area capital country population
BR 8.516 Brasilia Brazil 200.40
RU 17.100 Moscow Russia 143.50
IN 3.286 New Delhi India 1252.00
CH 9.597 Beijing China 1357.00
SA 1.221 Pretoria South Africa 52.98
INTERMEDIATE PYTHON
DataFrame from CSV file
brics.csv
,country,capital,area,population
BR,Brazil,Brasilia,8.516,200.4
RU,Russia,Moscow,17.10,143.5
IN,India,New Delhi,3.286,1252
CH,China,Beijing,9.597,1357
SA,South Africa,Pretoria,1.221,52.98
CSV = comma-separated values
INTERMEDIATE PYTHON
DataFrame from CSV file
brics.csv
,country,capital,area,population
BR,Brazil,Brasilia,8.516,200.4
RU,Russia,Moscow,17.10,143.5
IN,India,New Delhi,3.286,1252
CH,China,Beijing,9.597,1357
SA,South Africa,Pretoria,1.221,52.98
brics = pd.read_csv("path/to/brics.csv")
brics
Unnamed: 0 country capital area population
0 BR Brazil Brasilia 8.516 200.40
1 RU Russia Moscow 17.100 143.50
2 IN India New Delhi 3.286 1252.00
3 CH China Beijing 9.597 1357.00
4 SA South Africa Pretoria 1.221 52.98
INTERMEDIATE PYTHON
DataFrame from CSV file
brics = pd.read_csv("path/to/brics.csv", index_col = 0)
brics
country population area capital
BR Brazil 200 8515767 Brasilia
RU Russia 144 17098242 Moscow
IN India 1252 3287590 New Delhi
CH China 1357 9596961 Beijing
SA South Africa 55 1221037 Pretoria
Let's practice!
INTERMEDIATE PYTHON
Pandas, Part 2
INTERMEDIATE PYTHON
Hugo Bowne-Anderson
Data Scientist at DataCamp
INTERMEDIATE PYTHON
brics
import pandas as pd
brics = pd.read_csv("path/to/brics.csv", index_col = 0)
brics
country capital area population
BR Brazil Brasilia 8.516 200.40
RU Russia Moscow 17.100 143.50
IN India New Delhi 3.286 1252.00
CH China Beijing 9.597 1357.00
SA South Africa Pretoria 1.221 52.98
INTERMEDIATE PYTHON
Index and select data
Square brackets
Advanced methods
loc
iloc
INTERMEDIATE PYTHON
Column Access [ ]
country capital area population
BR Brazil Brasilia 8.516 200.40
RU Russia Moscow 17.100 143.50
IN India New Delhi 3.286 1252.00
CH China Beijing 9.597 1357.00
SA South Africa Pretoria 1.221 52.98
brics["country"]
BR Brazil
RU Russia
IN India
CH China
SA South Africa
Name: country, dtype: object
INTERMEDIATE PYTHON
Column Access [ ]
country capital area population
BR Brazil Brasilia 8.516 200.40
RU Russia Moscow 17.100 143.50
IN India New Delhi 3.286 1252.00
CH China Beijing 9.597 1357.00
SA South Africa Pretoria 1.221 52.98
type(brics["country"])
pandas.core.series.Series
1D labelled array
INTERMEDIATE PYTHON
Column Access [ ]
country capital area population
BR Brazil Brasilia 8.516 200.40
RU Russia Moscow 17.100 143.50
IN India New Delhi 3.286 1252.00
CH China Beijing 9.597 1357.00
SA South Africa Pretoria 1.221 52.98
brics[["country"]]
country
BR Brazil
RU Russia
IN India
CH China
SA South Africa
INTERMEDIATE PYTHON
Column Access [ ]
country capital area population
BR Brazil Brasilia 8.516 200.40
RU Russia Moscow 17.100 143.50
IN India New Delhi 3.286 1252.00
CH China Beijing 9.597 1357.00
SA South Africa Pretoria 1.221 52.98
type(brics[["country"]])
pandas.core.frame.DataFrame
INTERMEDIATE PYTHON
Column Access [ ]
country capital area population
BR Brazil Brasilia 8.516 200.40
RU Russia Moscow 17.100 143.50
IN India New Delhi 3.286 1252.00
CH China Beijing 9.597 1357.00
SA South Africa Pretoria 1.221 52.98
brics[["country", "capital"]]
country capital
BR Brazil Brasilia
RU Russia Moscow
IN India New Delhi
CH China Beijing
SA South Africa Pretoria
INTERMEDIATE PYTHON
Row Access [ ]
country capital area population
BR Brazil Brasilia 8.516 200.40
RU Russia Moscow 17.100 143.50
IN India New Delhi 3.286 1252.00
CH China Beijing 9.597 1357.00
SA South Africa Pretoria 1.221 52.98
brics[1:4]
country capital area population
RU Russia Moscow 17.100 143.5
IN India New Delhi 3.286 1252.0
CH China Beijing 9.597 1357.0
INTERMEDIATE PYTHON
Row Access [ ]
country capital area population
BR Brazil Brasilia 8.516 200.40 * 0 *
RU Russia Moscow 17.100 143.50 * 1 *
IN India New Delhi 3.286 1252.00 * 2 *
CH China Beijing 9.597 1357.00 * 3 *
SA South Africa Pretoria 1.221 52.98 * 4 *
brics[1:4]
country capital area population
RU Russia Moscow 17.100 143.5
IN India New Delhi 3.286 1252.0
CH China Beijing 9.597 1357.0
INTERMEDIATE PYTHON
Discussion [ ]
Square brackets: limited functionality
Ideally
2D Numpy arrays
my_array[rows, columns]
pandas
loc (label-based)
iloc (integer position-based)
INTERMEDIATE PYTHON
Row Access loc
country capital area population
BR Brazil Brasilia 8.516 200.40
RU Russia Moscow 17.100 143.50
IN India New Delhi 3.286 1252.00
CH China Beijing 9.597 1357.00
SA South Africa Pretoria 1.221 52.98
brics.loc["RU"]
country Russia
capital Moscow
area 17.1
population 143.5
Name: RU, dtype: object
Row as pandas Series
INTERMEDIATE PYTHON
Row Access loc
country capital area population
BR Brazil Brasilia 8.516 200.40
RU Russia Moscow 17.100 143.50
IN India New Delhi 3.286 1252.00
CH China Beijing 9.597 1357.00
SA South Africa Pretoria 1.221 52.98
brics.loc[["RU"]]
country capital area population
RU Russia Moscow 17.1 143.5
DataFrame
INTERMEDIATE PYTHON
Row Access loc
country capital area population
BR Brazil Brasilia 8.516 200.40
RU Russia Moscow 17.100 143.50
IN India New Delhi 3.286 1252.00
CH China Beijing 9.597 1357.00
SA South Africa Pretoria 1.221 52.98
brics.loc[["RU", "IN", "CH"]]
country capital area population
RU Russia Moscow 17.100 143.5
IN India New Delhi 3.286 1252.0
CH China Beijing 9.597 1357.0
INTERMEDIATE PYTHON
Row & Column loc
country capital area population
BR Brazil Brasilia 8.516 200.40
RU Russia Moscow 17.100 143.50
IN India New Delhi 3.286 1252.00
CH China Beijing 9.597 1357.00
SA South Africa Pretoria 1.221 52.98
brics.loc[["RU", "IN", "CH"], ["country", "capital"]]
country capital
RU Russia Moscow
IN India New Delhi
CH China Beijing
INTERMEDIATE PYTHON
Row & Column loc
country capital area population
BR Brazil Brasilia 8.516 200.40
RU Russia Moscow 17.100 143.50
IN India New Delhi 3.286 1252.00
CH China Beijing 9.597 1357.00
SA South Africa Pretoria 1.221 52.98
brics.loc[:, ["country", "capital"]]
country capital
BR Brazil Brasilia
RU Russia Moscow
IN India New Delhi
CH China Beijing
SA South Africa Pretoria
INTERMEDIATE PYTHON
Recap
Square brackets
Column access brics[["country", "capital"]]
Row access: only through slicing brics[1:4]
loc (label-based)
Row access brics.loc[["RU", "IN", "CH"]]
Column access brics.loc[:, ["country", "capital"]]
Row & Column access
brics.loc[
["RU", "IN", "CH"],
["country", "capital"]
]
INTERMEDIATE PYTHON
Row Access iloc
country capital area population
BR Brazil Brasilia 8.516 200.40
RU Russia Moscow 17.100 143.50
IN India New Delhi 3.286 1252.00
CH China Beijing 9.597 1357.00
SA South Africa Pretoria 1.221 52.98
brics.loc[["RU"]]
country capital area population
RU Russia Moscow 17.1 143.5
brics.iloc[[1]]
country capital area population
RU Russia Moscow 17.1 143.5
INTERMEDIATE PYTHON
Row Access iloc
country capital area population
BR Brazil Brasilia 8.516 200.40
RU Russia Moscow 17.100 143.50
IN India New Delhi 3.286 1252.00
CH China Beijing 9.597 1357.00
SA South Africa Pretoria 1.221 52.98
brics.loc[["RU", "IN", "CH"]]
country capital area population
RU Russia Moscow 17.100 143.5
IN India New Delhi 3.286 1252.0
CH China Beijing 9.597 1357.0
INTERMEDIATE PYTHON
Row Access iloc
country capital area population
BR Brazil Brasilia 8.516 200.40
RU Russia Moscow 17.100 143.50
IN India New Delhi 3.286 1252.00
CH China Beijing 9.597 1357.00
SA South Africa Pretoria 1.221 52.98
brics.iloc[[1,2,3]]
country capital area population
RU Russia Moscow 17.100 143.5
IN India New Delhi 3.286 1252.0
CH China Beijing 9.597 1357.0
INTERMEDIATE PYTHON
Row & Column iloc
country capital area population
BR Brazil Brasilia 8.516 200.40
RU Russia Moscow 17.100 143.50
IN India New Delhi 3.286 1252.00
CH China Beijing 9.597 1357.00
SA South Africa Pretoria 1.221 52.98
brics.loc[["RU", "IN", "CH"], ["country", "capital"]]
country capital
RU Russia Moscow
IN India New Delhi
CH China Beijing
INTERMEDIATE PYTHON
Row & Column iloc
country capital area population
BR Brazil Brasilia 8.516 200.40
RU Russia Moscow 17.100 143.50
IN India New Delhi 3.286 1252.00
CH China Beijing 9.597 1357.00
SA South Africa Pretoria 1.221 52.98
brics.iloc[[1,2,3], [0, 1]]
country capital
RU Russia Moscow
IN India New Delhi
CH China Beijing
INTERMEDIATE PYTHON
Row & Column iloc
country capital area population
BR Brazil Brasilia 8.516 200.40
RU Russia Moscow 17.100 143.50
IN India New Delhi 3.286 1252.00
CH China Beijing 9.597 1357.00
SA South Africa Pretoria 1.221 52.98
brics.loc[:, ["country", "capital"]]
country capital
BR Brazil Brasilia
RU Russia Moscow
IN India New Delhi
CH China Beijing
SA South Africa Pretoria
INTERMEDIATE PYTHON
Row & Column iloc
country capital area population
BR Brazil Brasilia 8.516 200.40
RU Russia Moscow 17.100 143.50
IN India New Delhi 3.286 1252.00
CH China Beijing 9.597 1357.00
SA South Africa Pretoria 1.221 52.98
brics.iloc[:, [0,1]]
country capital
BR Brazil Brasilia
RU Russia Moscow
IN India New Delhi
CH China Beijing
SA South Africa Pretoria
Let's practice!
INTERMEDIATE PYTHON

More Related Content

Recently uploaded

The Building Blocks of QuestDB, a Time Series Database
The Building Blocks of QuestDB, a Time Series DatabaseThe Building Blocks of QuestDB, a Time Series Database
The Building Blocks of QuestDB, a Time Series Database
javier ramirez
 
The Ipsos - AI - Monitor 2024 Report.pdf
The  Ipsos - AI - Monitor 2024 Report.pdfThe  Ipsos - AI - Monitor 2024 Report.pdf
The Ipsos - AI - Monitor 2024 Report.pdf
Social Samosa
 
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
bopyb
 
原版一比一利兹贝克特大学毕业证(LeedsBeckett毕业证书)如何办理
原版一比一利兹贝克特大学毕业证(LeedsBeckett毕业证书)如何办理原版一比一利兹贝克特大学毕业证(LeedsBeckett毕业证书)如何办理
原版一比一利兹贝克特大学毕业证(LeedsBeckett毕业证书)如何办理
wyddcwye1
 
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
nuttdpt
 
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
Social Samosa
 
Experts live - Improving user adoption with AI
Experts live - Improving user adoption with AIExperts live - Improving user adoption with AI
Experts live - Improving user adoption with AI
jitskeb
 
Palo Alto Cortex XDR presentation .......
Palo Alto Cortex XDR presentation .......Palo Alto Cortex XDR presentation .......
Palo Alto Cortex XDR presentation .......
Sachin Paul
 
Open Source Contributions to Postgres: The Basics POSETTE 2024
Open Source Contributions to Postgres: The Basics POSETTE 2024Open Source Contributions to Postgres: The Basics POSETTE 2024
Open Source Contributions to Postgres: The Basics POSETTE 2024
ElizabethGarrettChri
 
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
nyfuhyz
 
Intelligence supported media monitoring in veterinary medicine
Intelligence supported media monitoring in veterinary medicineIntelligence supported media monitoring in veterinary medicine
Intelligence supported media monitoring in veterinary medicine
AndrzejJarynowski
 
Global Situational Awareness of A.I. and where its headed
Global Situational Awareness of A.I. and where its headedGlobal Situational Awareness of A.I. and where its headed
Global Situational Awareness of A.I. and where its headed
vikram sood
 
Udemy_2024_Global_Learning_Skills_Trends_Report (1).pdf
Udemy_2024_Global_Learning_Skills_Trends_Report (1).pdfUdemy_2024_Global_Learning_Skills_Trends_Report (1).pdf
Udemy_2024_Global_Learning_Skills_Trends_Report (1).pdf
Fernanda Palhano
 
Everything you wanted to know about LIHTC
Everything you wanted to know about LIHTCEverything you wanted to know about LIHTC
Everything you wanted to know about LIHTC
Roger Valdez
 
Analysis insight about a Flyball dog competition team's performance
Analysis insight about a Flyball dog competition team's performanceAnalysis insight about a Flyball dog competition team's performance
Analysis insight about a Flyball dog competition team's performance
roli9797
 
End-to-end pipeline agility - Berlin Buzzwords 2024
End-to-end pipeline agility - Berlin Buzzwords 2024End-to-end pipeline agility - Berlin Buzzwords 2024
End-to-end pipeline agility - Berlin Buzzwords 2024
Lars Albertsson
 
一比一原版(Unimelb毕业证书)墨尔本大学毕业证如何办理
一比一原版(Unimelb毕业证书)墨尔本大学毕业证如何办理一比一原版(Unimelb毕业证书)墨尔本大学毕业证如何办理
一比一原版(Unimelb毕业证书)墨尔本大学毕业证如何办理
xclpvhuk
 
Learn SQL from basic queries to Advance queries
Learn SQL from basic queries to Advance queriesLearn SQL from basic queries to Advance queries
Learn SQL from basic queries to Advance queries
manishkhaire30
 
DSSML24_tspann_CodelessGenerativeAIPipelines
DSSML24_tspann_CodelessGenerativeAIPipelinesDSSML24_tspann_CodelessGenerativeAIPipelines
DSSML24_tspann_CodelessGenerativeAIPipelines
Timothy Spann
 
Population Growth in Bataan: The effects of population growth around rural pl...
Population Growth in Bataan: The effects of population growth around rural pl...Population Growth in Bataan: The effects of population growth around rural pl...
Population Growth in Bataan: The effects of population growth around rural pl...
Bill641377
 

Recently uploaded (20)

The Building Blocks of QuestDB, a Time Series Database
The Building Blocks of QuestDB, a Time Series DatabaseThe Building Blocks of QuestDB, a Time Series Database
The Building Blocks of QuestDB, a Time Series Database
 
The Ipsos - AI - Monitor 2024 Report.pdf
The  Ipsos - AI - Monitor 2024 Report.pdfThe  Ipsos - AI - Monitor 2024 Report.pdf
The Ipsos - AI - Monitor 2024 Report.pdf
 
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
 
原版一比一利兹贝克特大学毕业证(LeedsBeckett毕业证书)如何办理
原版一比一利兹贝克特大学毕业证(LeedsBeckett毕业证书)如何办理原版一比一利兹贝克特大学毕业证(LeedsBeckett毕业证书)如何办理
原版一比一利兹贝克特大学毕业证(LeedsBeckett毕业证书)如何办理
 
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
 
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
 
Experts live - Improving user adoption with AI
Experts live - Improving user adoption with AIExperts live - Improving user adoption with AI
Experts live - Improving user adoption with AI
 
Palo Alto Cortex XDR presentation .......
Palo Alto Cortex XDR presentation .......Palo Alto Cortex XDR presentation .......
Palo Alto Cortex XDR presentation .......
 
Open Source Contributions to Postgres: The Basics POSETTE 2024
Open Source Contributions to Postgres: The Basics POSETTE 2024Open Source Contributions to Postgres: The Basics POSETTE 2024
Open Source Contributions to Postgres: The Basics POSETTE 2024
 
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
 
Intelligence supported media monitoring in veterinary medicine
Intelligence supported media monitoring in veterinary medicineIntelligence supported media monitoring in veterinary medicine
Intelligence supported media monitoring in veterinary medicine
 
Global Situational Awareness of A.I. and where its headed
Global Situational Awareness of A.I. and where its headedGlobal Situational Awareness of A.I. and where its headed
Global Situational Awareness of A.I. and where its headed
 
Udemy_2024_Global_Learning_Skills_Trends_Report (1).pdf
Udemy_2024_Global_Learning_Skills_Trends_Report (1).pdfUdemy_2024_Global_Learning_Skills_Trends_Report (1).pdf
Udemy_2024_Global_Learning_Skills_Trends_Report (1).pdf
 
Everything you wanted to know about LIHTC
Everything you wanted to know about LIHTCEverything you wanted to know about LIHTC
Everything you wanted to know about LIHTC
 
Analysis insight about a Flyball dog competition team's performance
Analysis insight about a Flyball dog competition team's performanceAnalysis insight about a Flyball dog competition team's performance
Analysis insight about a Flyball dog competition team's performance
 
End-to-end pipeline agility - Berlin Buzzwords 2024
End-to-end pipeline agility - Berlin Buzzwords 2024End-to-end pipeline agility - Berlin Buzzwords 2024
End-to-end pipeline agility - Berlin Buzzwords 2024
 
一比一原版(Unimelb毕业证书)墨尔本大学毕业证如何办理
一比一原版(Unimelb毕业证书)墨尔本大学毕业证如何办理一比一原版(Unimelb毕业证书)墨尔本大学毕业证如何办理
一比一原版(Unimelb毕业证书)墨尔本大学毕业证如何办理
 
Learn SQL from basic queries to Advance queries
Learn SQL from basic queries to Advance queriesLearn SQL from basic queries to Advance queries
Learn SQL from basic queries to Advance queries
 
DSSML24_tspann_CodelessGenerativeAIPipelines
DSSML24_tspann_CodelessGenerativeAIPipelinesDSSML24_tspann_CodelessGenerativeAIPipelines
DSSML24_tspann_CodelessGenerativeAIPipelines
 
Population Growth in Bataan: The effects of population growth around rural pl...
Population Growth in Bataan: The effects of population growth around rural pl...Population Growth in Bataan: The effects of population growth around rural pl...
Population Growth in Bataan: The effects of population growth around rural pl...
 

Featured

Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
Christy Abraham Joy
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
Vit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
MindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
GetSmarter
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
Alireza Esmikhani
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
Project for Public Spaces & National Center for Biking and Walking
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
Erica Santiago
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Saba Software
 

Featured (20)

Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
 

chapter2.pdf

  • 1. Dictionaries, Part 1 INTERMEDIATE PYTHON Hugo Bowne-Anderson Data Scientist at DataCamp
  • 2. INTERMEDIATE PYTHON List pop = [30.55, 2.77, 39.21] countries = ["afghanistan", "albania", "algeria"] ind_alb = countries.index("albania") ind_alb 1 pop[ind_alb] 2.77 Not convenient Not intuitive
  • 3. INTERMEDIATE PYTHON Dictionary pop = [30.55, 2.77, 39.21] countries = ["afghanistan", "albania", "algeria"] ... { }
  • 4. INTERMEDIATE PYTHON Dictionary pop = [30.55, 2.77, 39.21] countries = ["afghanistan", "albania", "algeria"] ... {"afghanistan":30.55, }
  • 5. INTERMEDIATE PYTHON Dictionary pop = [30.55, 2.77, 39.21] countries = ["afghanistan", "albania", "algeria"] ... world = {"afghanistan":30.55, "albania":2.77, "algeria":39.21} world["albania"] 2.77
  • 7. Dictionaries, Part 2 INTERMEDIATE PYTHON Hugo Bowne-Anderson Data Scientist at DataCamp
  • 8. INTERMEDIATE PYTHON Recap world = {"afghanistan":30.55, "albania":2.77, "algeria":39.21} world["albania"] 2.77 world = {"afghanistan":30.55, "albania":2.77, "algeria":39.21, "albania":2.81} world {'afghanistan': 30.55, 'albania': 2.81, 'algeria': 39.21}
  • 9. INTERMEDIATE PYTHON Recap Keys have to be "immutable" objects {0:"hello", True:"dear", "two":"world"} {0: 'hello', True: 'dear', 'two': 'world'} {["just", "to", "test"]: "value"} TypeError: unhashable type: 'list'
  • 10. INTERMEDIATE PYTHON Principality of Sealand Source: Wikipedia 1
  • 11. INTERMEDIATE PYTHON Dictionary world["sealand"] = 0.000027 world {'afghanistan': 30.55, 'albania': 2.81, 'algeria': 39.21, 'sealand': 2.7e-05} "sealand" in world True
  • 12. INTERMEDIATE PYTHON Dictionary world["sealand"] = 0.000028 world {'afghanistan': 30.55, 'albania': 2.81, 'algeria': 39.21, 'sealand': 2.8e-05} del(world["sealand"]) world {'afghanistan': 30.55, 'albania': 2.81, 'algeria': 39.21}
  • 22. Pandas, Part 1 INTERMEDIATE PYTHON Hugo Bowne-Anderson Data Scientist at DataCamp
  • 26. INTERMEDIATE PYTHON Datasets in Python 2D Numpy array? One data type
  • 28. INTERMEDIATE PYTHON Datasets in Python pandas! High level data manipulation tool Wes McKinney Built on Numpy DataFrame
  • 29. INTERMEDIATE PYTHON DataFrame brics country capital area population BR Brazil Brasilia 8.516 200.40 RU Russia Moscow 17.100 143.50 IN India New Delhi 3.286 1252.00 CH China Beijing 9.597 1357.00 SA South Africa Pretoria 1.221 52.98
  • 30. INTERMEDIATE PYTHON DataFrame from Dictionary dict = { "country":["Brazil", "Russia", "India", "China", "South Africa"], "capital":["Brasilia", "Moscow", "New Delhi", "Beijing", "Pretoria"], "area":[8.516, 17.10, 3.286, 9.597, 1.221] "population":[200.4, 143.5, 1252, 1357, 52.98] } keys (column labels) values (data, column by column) import pandas as pd brics = pd.DataFrame(dict)
  • 31. INTERMEDIATE PYTHON DataFrame from Dictionary (2) brics area capital country population 0 8.516 Brasilia Brazil 200.40 1 17.100 Moscow Russia 143.50 2 3.286 New Delhi India 1252.00 3 9.597 Beijing China 1357.00 4 1.221 Pretoria South Africa 52.98 brics.index = ["BR", "RU", "IN", "CH", "SA"] brics area capital country population BR 8.516 Brasilia Brazil 200.40 RU 17.100 Moscow Russia 143.50 IN 3.286 New Delhi India 1252.00 CH 9.597 Beijing China 1357.00 SA 1.221 Pretoria South Africa 52.98
  • 32. INTERMEDIATE PYTHON DataFrame from CSV file brics.csv ,country,capital,area,population BR,Brazil,Brasilia,8.516,200.4 RU,Russia,Moscow,17.10,143.5 IN,India,New Delhi,3.286,1252 CH,China,Beijing,9.597,1357 SA,South Africa,Pretoria,1.221,52.98 CSV = comma-separated values
  • 33. INTERMEDIATE PYTHON DataFrame from CSV file brics.csv ,country,capital,area,population BR,Brazil,Brasilia,8.516,200.4 RU,Russia,Moscow,17.10,143.5 IN,India,New Delhi,3.286,1252 CH,China,Beijing,9.597,1357 SA,South Africa,Pretoria,1.221,52.98 brics = pd.read_csv("path/to/brics.csv") brics Unnamed: 0 country capital area population 0 BR Brazil Brasilia 8.516 200.40 1 RU Russia Moscow 17.100 143.50 2 IN India New Delhi 3.286 1252.00 3 CH China Beijing 9.597 1357.00 4 SA South Africa Pretoria 1.221 52.98
  • 34. INTERMEDIATE PYTHON DataFrame from CSV file brics = pd.read_csv("path/to/brics.csv", index_col = 0) brics country population area capital BR Brazil 200 8515767 Brasilia RU Russia 144 17098242 Moscow IN India 1252 3287590 New Delhi CH China 1357 9596961 Beijing SA South Africa 55 1221037 Pretoria
  • 36. Pandas, Part 2 INTERMEDIATE PYTHON Hugo Bowne-Anderson Data Scientist at DataCamp
  • 37. INTERMEDIATE PYTHON brics import pandas as pd brics = pd.read_csv("path/to/brics.csv", index_col = 0) brics country capital area population BR Brazil Brasilia 8.516 200.40 RU Russia Moscow 17.100 143.50 IN India New Delhi 3.286 1252.00 CH China Beijing 9.597 1357.00 SA South Africa Pretoria 1.221 52.98
  • 38. INTERMEDIATE PYTHON Index and select data Square brackets Advanced methods loc iloc
  • 39. INTERMEDIATE PYTHON Column Access [ ] country capital area population BR Brazil Brasilia 8.516 200.40 RU Russia Moscow 17.100 143.50 IN India New Delhi 3.286 1252.00 CH China Beijing 9.597 1357.00 SA South Africa Pretoria 1.221 52.98 brics["country"] BR Brazil RU Russia IN India CH China SA South Africa Name: country, dtype: object
  • 40. INTERMEDIATE PYTHON Column Access [ ] country capital area population BR Brazil Brasilia 8.516 200.40 RU Russia Moscow 17.100 143.50 IN India New Delhi 3.286 1252.00 CH China Beijing 9.597 1357.00 SA South Africa Pretoria 1.221 52.98 type(brics["country"]) pandas.core.series.Series 1D labelled array
  • 41. INTERMEDIATE PYTHON Column Access [ ] country capital area population BR Brazil Brasilia 8.516 200.40 RU Russia Moscow 17.100 143.50 IN India New Delhi 3.286 1252.00 CH China Beijing 9.597 1357.00 SA South Africa Pretoria 1.221 52.98 brics[["country"]] country BR Brazil RU Russia IN India CH China SA South Africa
  • 42. INTERMEDIATE PYTHON Column Access [ ] country capital area population BR Brazil Brasilia 8.516 200.40 RU Russia Moscow 17.100 143.50 IN India New Delhi 3.286 1252.00 CH China Beijing 9.597 1357.00 SA South Africa Pretoria 1.221 52.98 type(brics[["country"]]) pandas.core.frame.DataFrame
  • 43. INTERMEDIATE PYTHON Column Access [ ] country capital area population BR Brazil Brasilia 8.516 200.40 RU Russia Moscow 17.100 143.50 IN India New Delhi 3.286 1252.00 CH China Beijing 9.597 1357.00 SA South Africa Pretoria 1.221 52.98 brics[["country", "capital"]] country capital BR Brazil Brasilia RU Russia Moscow IN India New Delhi CH China Beijing SA South Africa Pretoria
  • 44. INTERMEDIATE PYTHON Row Access [ ] country capital area population BR Brazil Brasilia 8.516 200.40 RU Russia Moscow 17.100 143.50 IN India New Delhi 3.286 1252.00 CH China Beijing 9.597 1357.00 SA South Africa Pretoria 1.221 52.98 brics[1:4] country capital area population RU Russia Moscow 17.100 143.5 IN India New Delhi 3.286 1252.0 CH China Beijing 9.597 1357.0
  • 45. INTERMEDIATE PYTHON Row Access [ ] country capital area population BR Brazil Brasilia 8.516 200.40 * 0 * RU Russia Moscow 17.100 143.50 * 1 * IN India New Delhi 3.286 1252.00 * 2 * CH China Beijing 9.597 1357.00 * 3 * SA South Africa Pretoria 1.221 52.98 * 4 * brics[1:4] country capital area population RU Russia Moscow 17.100 143.5 IN India New Delhi 3.286 1252.0 CH China Beijing 9.597 1357.0
  • 46. INTERMEDIATE PYTHON Discussion [ ] Square brackets: limited functionality Ideally 2D Numpy arrays my_array[rows, columns] pandas loc (label-based) iloc (integer position-based)
  • 47. INTERMEDIATE PYTHON Row Access loc country capital area population BR Brazil Brasilia 8.516 200.40 RU Russia Moscow 17.100 143.50 IN India New Delhi 3.286 1252.00 CH China Beijing 9.597 1357.00 SA South Africa Pretoria 1.221 52.98 brics.loc["RU"] country Russia capital Moscow area 17.1 population 143.5 Name: RU, dtype: object Row as pandas Series
  • 48. INTERMEDIATE PYTHON Row Access loc country capital area population BR Brazil Brasilia 8.516 200.40 RU Russia Moscow 17.100 143.50 IN India New Delhi 3.286 1252.00 CH China Beijing 9.597 1357.00 SA South Africa Pretoria 1.221 52.98 brics.loc[["RU"]] country capital area population RU Russia Moscow 17.1 143.5 DataFrame
  • 49. INTERMEDIATE PYTHON Row Access loc country capital area population BR Brazil Brasilia 8.516 200.40 RU Russia Moscow 17.100 143.50 IN India New Delhi 3.286 1252.00 CH China Beijing 9.597 1357.00 SA South Africa Pretoria 1.221 52.98 brics.loc[["RU", "IN", "CH"]] country capital area population RU Russia Moscow 17.100 143.5 IN India New Delhi 3.286 1252.0 CH China Beijing 9.597 1357.0
  • 50. INTERMEDIATE PYTHON Row & Column loc country capital area population BR Brazil Brasilia 8.516 200.40 RU Russia Moscow 17.100 143.50 IN India New Delhi 3.286 1252.00 CH China Beijing 9.597 1357.00 SA South Africa Pretoria 1.221 52.98 brics.loc[["RU", "IN", "CH"], ["country", "capital"]] country capital RU Russia Moscow IN India New Delhi CH China Beijing
  • 51. INTERMEDIATE PYTHON Row & Column loc country capital area population BR Brazil Brasilia 8.516 200.40 RU Russia Moscow 17.100 143.50 IN India New Delhi 3.286 1252.00 CH China Beijing 9.597 1357.00 SA South Africa Pretoria 1.221 52.98 brics.loc[:, ["country", "capital"]] country capital BR Brazil Brasilia RU Russia Moscow IN India New Delhi CH China Beijing SA South Africa Pretoria
  • 52. INTERMEDIATE PYTHON Recap Square brackets Column access brics[["country", "capital"]] Row access: only through slicing brics[1:4] loc (label-based) Row access brics.loc[["RU", "IN", "CH"]] Column access brics.loc[:, ["country", "capital"]] Row & Column access brics.loc[ ["RU", "IN", "CH"], ["country", "capital"] ]
  • 53. INTERMEDIATE PYTHON Row Access iloc country capital area population BR Brazil Brasilia 8.516 200.40 RU Russia Moscow 17.100 143.50 IN India New Delhi 3.286 1252.00 CH China Beijing 9.597 1357.00 SA South Africa Pretoria 1.221 52.98 brics.loc[["RU"]] country capital area population RU Russia Moscow 17.1 143.5 brics.iloc[[1]] country capital area population RU Russia Moscow 17.1 143.5
  • 54. INTERMEDIATE PYTHON Row Access iloc country capital area population BR Brazil Brasilia 8.516 200.40 RU Russia Moscow 17.100 143.50 IN India New Delhi 3.286 1252.00 CH China Beijing 9.597 1357.00 SA South Africa Pretoria 1.221 52.98 brics.loc[["RU", "IN", "CH"]] country capital area population RU Russia Moscow 17.100 143.5 IN India New Delhi 3.286 1252.0 CH China Beijing 9.597 1357.0
  • 55. INTERMEDIATE PYTHON Row Access iloc country capital area population BR Brazil Brasilia 8.516 200.40 RU Russia Moscow 17.100 143.50 IN India New Delhi 3.286 1252.00 CH China Beijing 9.597 1357.00 SA South Africa Pretoria 1.221 52.98 brics.iloc[[1,2,3]] country capital area population RU Russia Moscow 17.100 143.5 IN India New Delhi 3.286 1252.0 CH China Beijing 9.597 1357.0
  • 56. INTERMEDIATE PYTHON Row & Column iloc country capital area population BR Brazil Brasilia 8.516 200.40 RU Russia Moscow 17.100 143.50 IN India New Delhi 3.286 1252.00 CH China Beijing 9.597 1357.00 SA South Africa Pretoria 1.221 52.98 brics.loc[["RU", "IN", "CH"], ["country", "capital"]] country capital RU Russia Moscow IN India New Delhi CH China Beijing
  • 57. INTERMEDIATE PYTHON Row & Column iloc country capital area population BR Brazil Brasilia 8.516 200.40 RU Russia Moscow 17.100 143.50 IN India New Delhi 3.286 1252.00 CH China Beijing 9.597 1357.00 SA South Africa Pretoria 1.221 52.98 brics.iloc[[1,2,3], [0, 1]] country capital RU Russia Moscow IN India New Delhi CH China Beijing
  • 58. INTERMEDIATE PYTHON Row & Column iloc country capital area population BR Brazil Brasilia 8.516 200.40 RU Russia Moscow 17.100 143.50 IN India New Delhi 3.286 1252.00 CH China Beijing 9.597 1357.00 SA South Africa Pretoria 1.221 52.98 brics.loc[:, ["country", "capital"]] country capital BR Brazil Brasilia RU Russia Moscow IN India New Delhi CH China Beijing SA South Africa Pretoria
  • 59. INTERMEDIATE PYTHON Row & Column iloc country capital area population BR Brazil Brasilia 8.516 200.40 RU Russia Moscow 17.100 143.50 IN India New Delhi 3.286 1252.00 CH China Beijing 9.597 1357.00 SA South Africa Pretoria 1.221 52.98 brics.iloc[:, [0,1]] country capital BR Brazil Brasilia RU Russia Moscow IN India New Delhi CH China Beijing SA South Africa Pretoria