Skip to content

Instantly share code, notes, and snippets.

View L-Lewis's full-sized avatar

Laura Lewis L-Lewis

View GitHub Profile
@L-Lewis
L-Lewis / mapping-boroughs.py
Created May 16, 2019 13:21
Using geopandas to plot the number and median price of Airbnb listings in each London borough
import geopandas as gpd
# Importing the London borough boundary GeoJSON file as a dataframe in geopandas
map_df = gpd.read_file('data/neighbourhoods.geojson')
# Creating a dataframe of listing counts and median price by borough
borough_df = pd.DataFrame(df.groupby('borough').size())
borough_df.rename(columns={0: 'number_of_listings'}, inplace=True)
borough_df['median_price'] = df.groupby('borough').price.median().values
@L-Lewis
L-Lewis / amenities-set.py
Created May 16, 2019 12:36
Creating a set of all possible amenities in the Airbnb dataset
amenities_list = list(df.amenities)
amenities_list_string = " ".join(amenities_list)
amenities_list_string = amenities_list_string.replace('{', '')
amenities_list_string = amenities_list_string.replace('}', ',')
amenities_list_string = amenities_list_string.replace('"', '')
amenities_set = [x.strip() for x in amenities_list_string.split(',')]
amenities_set = set(amenities_set)
amenities_set