Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.86 KB | None | 0 0
  1. import numpy as np
  2. import geopandas as gp
  3. #import geoplot
  4. import pandas as pd
  5. from shapely.geometry import Point
  6. import matplotlib.pyplot as plt
  7.  
  8. geojs = gp.read_file('data/neighbourhoods.geojson')
  9.  
  10. df = pd.read_csv('data/cleaned/data_cleaned.csv')
  11. df = df[['latitude', 'longitude', 'price']]
  12.  
  13. df['coords'] = list(zip(df.longitude, df.latitude))
  14. df['coords'] = df['coords'].apply(Point)
  15. df['price'] = np.exp(df['price'])
  16. df = df[df['price'] <= 200]
  17.  
  18. # df.drop('longitude','latitude')
  19.  
  20.  
  21. gdf = gp.GeoDataFrame(df, geometry='coords')
  22.  
  23. base = geojs.plot(color='white', edgecolor='black',
  24.                   linewidth=1, figsize=(10, 10))
  25.  
  26. gdf.plot(ax=base, marker='o', column='price', markersize=1, legend=True)
  27.  
  28. plt.xlabel('Longitude')
  29. plt.ylabel('Latitude')
  30. plt.title('NYC Airbnb Data Price Range')
  31.  
  32. plt.savefig('Price_map.svg', bbox_inches='tight')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement