Professional Documents
Culture Documents
ipynb - Colaboratory
import pandas as pd
huk_df = pd.read_csv('/content/sample_data/listings-Bristol-UK.csv')
display(huk_df)
City View
- Sarah's
0 70820 360195 Sarah NaN Windmill Hill 51.43994 -2.59173
double
room.
City
Centre-
1 117122 591555 Marcus NaN Clifton 51.45051 -2.61054
Waterside
Retreat
The White
Room -
Central
2 176306 708175 Orla NaN Bedminster 51.44101 -2.60121
Bristol Art
House
Ga...
Peaceful
Safe
Home &
3 307634 Clear 1582810 Wendy NaN Easton 51.46641 -2.55533
Space
'The Lilac
Room'
HUGE
Room
4 322906 CENTRAL 1156132 NaN NaN Ashley 51.46668 -2.58274
location
House
Comfy
Classic
Studio -
1539 48696902 226804666 Miroslav NaN Central 51.46113 -2.59244
LOS 12
months
10% off
Tidy Basic
Studio -
1540 48696977 LOS 12 226804666 Miroslav NaN Central 51.46061 -2.59266
months
10% off
Open &
Spacious
2BD
1541 48707074 380422424 Rebecca NaN Central 51.45422 -2.59725
Apartment
in Central
Bristol
Superb
En Suite
1542 48715639 room with 178961162 Ella NaN St George West 51.46214 -2.54421
free
parking
Double
room
central
1543 48725946 Bristol, 56470400 Sookie NaN Easton 51.46347 -2.55796
home
away from
home
huk_df['City']=('Bristol')
display(huk_df)
https://colab.research.google.com/drive/1ddY0S8jsElqEtATwuCIWJaCFbh8P9lh3#printMode=true 1/10
07/12/2022 00:31 Untitled3.ipynb - Colaboratory
City View
- Sarah's
0 70820 360195 Sarah NaN Windmill Hill 51.43994 -2.59173
double
room.
City
Centre-
1 117122 591555 Marcus NaN Clifton 51.45051 -2.61054
Waterside
Retreat
The White
Room -
Central
2 176306 708175 Orla NaN Bedminster 51.44101 -2.60121
Bristol Art
House
Ga...
Peaceful
Safe
Home &
3 307634 Clear 1582810 Wendy NaN Easton 51.46641 -2.55533
Space
'The Lilac
Room'
HUGE
Room
4 322906 CENTRAL 1156132 NaN NaN Ashley 51.46668 -2.58274
location
House
Comfy
Classic
Studio -
1539 48696902 226804666 Miroslav NaN Central 51.46113 -2.59244
LOS 12
months
10% off
Tidy Basic
Studio -
1540 48696977 LOS 12 226804666 Miroslav NaN Central 51.46061 -2.59266
months
10% off
Open &
Spacious
2BD
1541 48707074 380422424 Rebecca NaN Central 51.45422 -2.59725
Apartment
in Central
Bristol
Superb
En Suite
1542 48715639 room with 178961162 Ella NaN St George West 51.46214 -2.54421
free
parking
Double
room
central
1543 48725946 Bristol, 56470400 Sookie NaN Easton 51.46347 -2.55796
home
away from
home
huk_lon_df = pd.read_csv('/content/sample_data/listings-Londres.csv')
1544 rows × 17 columns
huk_df = huk_df.append(huk_lon_df)
display(huk_df)
https://colab.research.google.com/drive/1ddY0S8jsElqEtATwuCIWJaCFbh8P9lh3#printMode=true 2/10
07/12/2022 00:31 Untitled3.ipynb - Colaboratory
City View -
Sarah's
0 70820 360195 Sarah NaN Windmill Hill 51.43994 -2.591
double
room.
City
Centre-
1 117122 591555 Marcus NaN Clifton 51.45051 -2.610
Waterside
Retreat
The White
Room -
Central
2 176306 708175 Orla NaN Bedminster 51.44101 -2.601
Bristol Art
House
Ga...
Peaceful
Safe Home
& Clear
3 307634 1582810 Wendy NaN Easton 51.46641 -2.555
Space 'The
Lilac
Room'
HUGE
Room
4 322906 CENTRAL 1156132 NaN NaN Ashley 51.46668 -2.582
location
House
Charming
3 Bed
74836 49142705 Apartment 17837404 Leyla NaN Westminster 51.49301 -0.141
in the heart
of Pimlico
Modern
Coach
74837 49143242 House on 24138574 Luke NaN Greenwich 51.47835 0.081
quiet
#vendas_df['Comissão'] = vendas_df['Comissão'].fillna(vendas_df['Comissão'].mean())
street.
huk_df['City'] = huk_df['City'].fillna('London')
display(huk_df) Brand new
74838 49143401 luxury 2725776 David NaN Redbridge 51.57215 0.060
room
Furnished
double
74839 49143952 room with 396379938 Chetna NaN Hillingdon 51.53186 -0.448
En-suite &
parking
https://colab.research.google.com/drive/1ddY0S8jsElqEtATwuCIWJaCFbh8P9lh3#printMode=true 3/10
07/12/2022 00:31 Untitled3.ipynb - Colaboratory
City View -
Sarah's
0 70820 360195 Sarah NaN Windmill Hill 51.43994 -2.591
double
room.
City
Centre-
1 117122 591555 Marcus NaN Clifton 51.45051 -2.610
Waterside
Retreat
The White
Room -
Central
2 176306 708175 Orla NaN Bedminster 51.44101 -2.601
Bristol Art
House
Ga...
Peaceful
Safe Home
hukwm_df = pd.DataFrame(huk_df.loc[huk_df['neighbourhood']
& Clear
3 307634 1582810 Wendy NaN Easton 51.46641 -2.555
=='Westminster',['neighbourhood','neighbourhood_group','room_type']])
Space 'The
Lilac
Room'
display(hukwm_df)
HUGE
Room
neighbourhood neighbourhood_group room_type
4 322906 CENTRAL 1156132 NaN NaN Ashley 51.46668 -2.582
3 Westminsterlocation NaN Entire home/apt
House
15 Westminster NaN Private room
... ... ... ... ... ... ... ...
30 Westminster NaN Entire home/apt
74835 49142644 Ensuitroom 220485426 Hemil NaN Brent 51.55166 -0.297
36 Westminster NaN Entire home/apt
84 Charming
Westminster NaN Entire home/apt
3 Bed
...
74836 ...
49142705 Apartment 17837404 ... Leyla ... NaN Westminster 51.49301 -0.141
in the heart
74791 Westminster
of Pimlico NaN Private room
Furnished
#Valoue counts, transações por loja
double
hukwest_df = pd.DataFrame(huk_df['neighbourhood'].value_counts())
74839 49143952 room with 396379938 Chetna NaN Hillingdon 51.53186 -0.448
display(hukwest_df) En-suite &
parking
neighbourhood
76384 rows × 17 columns
Westminster 8365
Hackney 5576
Camden 5119
... ...
Hillfields 9
Stockwood 7
67 rows × 1 columns
hukwest_1df = hukwest_df.reset_index()
display(hukwest_1df)
https://colab.research.google.com/drive/1ddY0S8jsElqEtATwuCIWJaCFbh8P9lh3#printMode=true 4/10
07/12/2022 00:31 Untitled3.ipynb - Colaboratory
index neighbourhood
0 Westminster 8365
2 Hackney 5576
4 Camden 5119
64 Hillfields 9
66 Stockwood 7
hukwest_1df = hukwest_1df.drop('neighbourhood', axis=1)
display(hukwest_1df)
67 rows × 2 columns
index
0 Westminster
1 Tower Hamlets
2 Hackney
4 Camden
... ...
64 Hillfields
66 Stockwood
67 rows × 1 columns
hukwest_1df['neighbourhood'] = hukwest_1df['index']
hukwest_1df.sort_values('neighbourhood')
display(hukwest_1df)
index neighbourhood
0 Westminster Westminster
2 Hackney Hackney
4 Camden Camden
64 Hillfields Hillfields
66 Stockwood Stockwood
67 rows × 2 columns
hukwest_1df = hukwest_1df.drop('index',axis =1)
display(hukwest_1df)
https://colab.research.google.com/drive/1ddY0S8jsElqEtATwuCIWJaCFbh8P9lh3#printMode=true 5/10
07/12/2022 00:31 Untitled3.ipynb - Colaboratory
neighbourhood
0 Westminster
1 Tower Hamlets
2 Hackney
4 Camden
... ...
64 Hillfields
66 Stockwood
67 rows × 1 columns
huk_sorted = hukwest_1df.sort_values('neighbourhood')
display(huk_sorted)
neighbourhood
34 Ashley
15 Barnet
47 Bedminster
... ...
17 Waltham Forest
8 Wandsworth
0 Westminster
41 Windmill Hill
67 rows × 1 columns
huk_sorted = huk_sorted.reset_index()
display(huk_sorted)
index neighbourhood
0 0 Ashley
3 3 Barnet
4 4 Bedminster
62 62 Waltham Forest
63 63 Wandsworth
65 65 Westminster
66 66 Windmill Hill
67 rows × 2 columns
huk_sorted = huk_sorted.drop('index',axis=1)
display(huk_sorted)
https://colab.research.google.com/drive/1ddY0S8jsElqEtATwuCIWJaCFbh8P9lh3#printMode=true 6/10
07/12/2022 00:31 Untitled3.ipynb - Colaboratory
neighbourhood
0 Ashley
3 Barnet
4 Bedminster
... ...
62 Waltham Forest
63 Wandsworth
lista = []
65 Westminster
for x in range(1,68):
66 Windmill Hill
lista.append(x)
print(lista)
67 rows × 1 columns
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
hukwest_2df = huk_sorted
liista_df = pd.DataFrame(lista)
display(liista_df)
0 1
1 2
2 3
3 4
4 5
... ...
62 63
63 64
64 65
65 66
66 67
67 rows × 1 columns
liista_df['neighbourhood_group'] = liista_df[0]
liista_df = liista_df.drop(0,axis=1)
display(liista_df)
https://colab.research.google.com/drive/1ddY0S8jsElqEtATwuCIWJaCFbh8P9lh3#printMode=true 7/10
07/12/2022 00:31 Untitled3.ipynb - Colaboratory
neighbourhood_group
0 1
# MERGE1 2
hukwest_2df['neighbourhood_group'] = lista
2
display(hukwest_2df) 3
3 4
neighbourhood neighbourhood_group
4 5
0 Ashley 1
... ...
1 Avonmouth & Lawrence Weston 2
62 63
2 Barking and Dagenham 3
63 64
3 Barnet 4
64 65
4 Bedminster 5
65 66
... ... ...
66 67
62 Waltham Forest 63
67 rows × 1 columns
63 Wandsworth 64
65 Westminster 66
66 Windmill Hill 67
67 rows × 2 columns
huk_1df = huk_df
huk_1df = huk_1df.drop('neighbourhood_group', axis=1)
display(huk_1df)
huk_1df = huk_1df.merge(hukwest_2df)
display(huk_1df)
https://colab.research.google.com/drive/1ddY0S8jsElqEtATwuCIWJaCFbh8P9lh3#printMode=true 8/10
07/12/2022 00:31 Untitled3.ipynb - Colaboratory
id name
name host_id
host_id host_name
host_name neighbourhood
neighbourhood latitude
latitude longitude
longitude room_type
room_type price
price
City
CityView
View- -
Sarah's
Sarah's Private
Private
0 70820 360195
360195 Sarah
Sarah Windmill
WindmillHill
Hill 51.43994
51.43994 -2.59173
-2.59173 30
30
double
double room
room
room.
room.
Private City
cosy
Centre-
flat, free Private
1 117122 591555 Marcus
Liz And Clifton 51.45051 -2.61054 Entire 66
1 5890872 Waterside
road 25846068 Windmill Hill 51.43808 -2.59473 room 52
James home/apt
parking
Retreat
and
garden
The White
Room
Victoria- Private
2 5984540 13625482 Celia Windmill Hill 51.43848 -2.58816 39
ParkCentral
Studio Private
room
2 176306 708175 Orla Bedminster 51.44101 -2.60121 29
Bristol Art room
Cosy
House dbl Private
3 7409409 38822661 Joe Windmill Hill 51.43882 -2.59344 28
bed nr cntr
Ga... room
City View,
Peaceful
Woodburner
Safe Home Private
4 8578293 360195 Sarah Windmill Hill 51.44024 -2.59174 30
or&Blanket
Clear room
Private
3 307634 Box room. 1582810 Wendy Easton 51.46641 -2.55533 30
Space 'The room
Lilac
... ... Room'... ... ... ... ... ... ... ...
Ensuite
HUGE
room
Roomin Private
76379 48605267 350653072 Marco Sutton 51.34224 -0.15640 45
quiet Private
room
4 322906 CENTRAL 1156132 NaN Ashley 51.46668 -2.58274 69
farmhouse room
location
House
LUXURY
... ... WFH
... ... ... ... ... ... ... ...
HOUSE,
Entire
76380 48730596 ALL MOD 39096436 Craig Sutton 51.38423 -0.23772 Private 80
74835 49142644 Ensuitroom home/apt
CONS, 220485426 Hemil Brent 51.55166 -0.29743
room
120
5MIN WALK
Charming
2 TR...
3 Bed
Ensuite 17837404 Entire
74836 49142705 Apartment Leyla Westminster 51.49301 -0.14183 Private 120
76381 48804341 home/apt
inBedroom
the heartin 272440442 Atif Sutton 51.34857 -0.16802
room
34
Sutton
of Pimlico
Private
Modern
Room
Coach Private
Entire
76382
74837 48909124
49143242 Wallington
House on 220392386
24138574 Shanna
Luke Sutton 51.47835
Greenwich 51.37726 -0.15850
0.08173 16
128
room
home/apt
hosted by
quiet
Shanna
street.
# huk_1df
Spacious
Brand new
huk_1df['price_R$'] = huk_1df['price'] * 5.85
Double Private
74838 49143401 luxury 2725776 David Redbridge 51.57215 0.06040 36
display(huk_1df) Room with room
Private
76383 48912823 room 394517816 Izzy Sutton 51.38397 -0.16626 25
Free room
Parking
Furnished
and
double
Garden
Private
74839 49143952 room with 396379938 Chetna Hillingdon 51.53186 -0.44866 28
76384 rows × 17 columns room
En-suite &
parking
https://colab.research.google.com/drive/1ddY0S8jsElqEtATwuCIWJaCFbh8P9lh3#printMode=true 9/10
07/12/2022 00:31 Untitled3.ipynb - Colaboratory
City View -
Sarah's Private
0 70820 360195 Sarah Windmill Hill 51.43994 -2.59173 30
double room
room.
Private cosy
flat, free
Liz And Entire
1 5890872 road 25846068 Windmill Hill 51.43808 -2.59473 52
James home/apt
parking and
garden
Victoria Private
2 5984540 13625482 Celia Windmill Hill 51.43848 -2.58816 39
Park Studio room
City View,
#pegar varias linhas e colunas com loc
Woodburner Private
4 8578293 360195 Sarah Windmill Hill 51.44024 -2.59174 30
#vendasns_df = pd.DataFrame(vendas_df.loc[vendas_df['ID Loja'] =='Norte Shopping',['ID Loja','Produto','Quantidade']])
or Blanket room
#display(vendasns_df) Box room.
eh_n = pd.DataFrame(huk_1df.loc[(huk_1df['room_type'] == 'Entire home/apt') & (huk_1df['minimum_nights'] <=5 ) & (huk_1df['City']=='Brist
... ... ... ... ... ... ... ... ... ...
display(eh_n)
Ensuite
room in Private
76379 48605267 350653072 Marco Sutton 51.34224 -0.15640 45
id quiet
room_type minimum_nights host_name neighbourhood price room
price_R$
farmhouse
1 5890872 Entire home/apt 2 Liz And James Windmill Hill 52 304.20
LUXURY
7 WFH
12828793 Entire home/apt 1 Katherine & Suresh Windmill Hill 58 339.30
HOUSE,
8 13237892
76380 48730596 Entire home/apt
ALL MOD 39096436 1Craig
Katherine & Suresh
Sutton 51.38423Windmill Hill
-0.23772 58 Entire339.30 80
home/apt
CONS,
9 13290486 Entire home/apt
5MIN WALK 2 Mark Windmill Hill 66 386.10
2 TR...
12 17211150 Entire home/apt 2 Helen Windmill Hill 130 760.50
Ensuite
... ... ... ... ... ... ...Private ...
76381 48804341 Bedroom in 272440442 Atif Sutton 51.34857 -0.16802 34
room
Sutton
1526 21245658 Entire home/apt 2 Catherine Filwood 50 292.50
Private
1530 37483548 Entire home/apt 4 Tiffany Filwood 81 473.85
Room
Private
76382 24212234
1535 48909124 Entire
Wallington
home/apt220392386 Shanna
2 Sutton
Ed St51.37726 -0.15850
George Troopers Hill 62 room362.70 16
hosted by
1539 33291040 EntireShanna
home/apt 2 NaN St George Troopers Hill 189 1105.65
https://colab.research.google.com/drive/1ddY0S8jsElqEtATwuCIWJaCFbh8P9lh3#printMode=true 10/10