Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import geopandas as gp
- import pandas as pd
- from shapely.geometry import Point
- import matplotlib.pyplot as plt
- import math
- geojs = gp.read_file('data/new_york_neighbourhoods.geojson')
- data = pd.read_csv('listings.csv')
- data = data[['latitude', 'longitude', 'price']]
- data['coords'] = list(zip(data.longitude, data.latitude))
- data['coords'] = data['coords'].apply(Point)
- data['price'] = np.exp(data['price'])
- data = data[data['price'] <= 200]
- gdf = gp.GeoDataFrame(data, geometry='coords')
- base = geojs.plot(
- color='white',
- edgecolor='black',
- linewidth=1,
- figsize=(10, 10)
- )
- gdf.plot(ax=base, marker='o', column='price', markersize=1, legend=True)
- plt.xlabel('Longitude')
- plt.ylabel('Latitude')
- plt.title('NYC Airbnb Data Price Range')
- plt.savefig('map_price.svg', bbox_inches='tight')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement