Paris WiFi Services

Read local data from a json file


In [1]:
import json

with open('../files/paris_wifi_services.json', 'r') as json_file:
    data_json = json.load(json_file)

Normalize the json data and build a DataFrame


In [2]:
import pandas
from pandas.io.json import json_normalize

df = pandas.DataFrame(json_normalize(data_json['records']))
df.head()


Out[2]:
datasetid recordid record_timestamp fields.cp fields.nom_site fields.arc_adresse fields.geo_point_2d fields.nombre_de_borne_wifi fields.idpw fields.geo_shape.type fields.geo_shape.coordinates fields.etat2 geometry.type geometry.coordinates
0 sites-disposant-du-service-paris-wi-fi 31c3bfd9ad944ec1bea07cbeb28dc6bb0653e530 2019-10-08T07:01:10.494000+00:00 75010 MEDIATHEQUE FRANCOISE SAGAN 8 RUE LEON SCHWARTZENBERG [48.8754298708, 2.35366677297] 11 PW0147 Point [2.353666772968424, 48.87542987081135] Opérationnel Point [2.35366677297, 48.8754298708]
1 sites-disposant-du-service-paris-wi-fi 322b5836dd2af4413728e67dc4432cf83dde06b1 2019-10-08T07:01:10.494000+00:00 75020 PARC DE BELLEVILLE (PARIS NATURE MAISON DE L'AIR) 27 RUE PIAT [48.8716051488, 2.38492475051] 1 PW0168 Point [2.384924750509342, 48.87160514880642] Opérationnel Point [2.38492475051, 48.8716051488]
2 sites-disposant-du-service-paris-wi-fi ec66708cf6e56caced0ae6485f68c0a44167636d 2019-10-08T07:01:10.494000+00:00 75013 JARDIN BRASSAI 59 BOULEVARD AUGUSTE BLANQUI [48.8292152156, 2.34951229427] 1 NaN Point [2.349512294267843, 48.82921521555871] En étude Point [2.34951229427, 48.8292152156]
3 sites-disposant-du-service-paris-wi-fi 6f37d419ab91b1d9b2972eafe2f5585c4d51f358 2019-10-08T07:01:10.494000+00:00 75007 BERGES RIVE GAUCHE - JARDIN FLOTTANT PORT DU GROS CAILLOU [48.8629641751, 2.30452468194] 3 PW0189 Point [2.30452468193794, 48.86296417505911] Opérationnel Point [2.30452468194, 48.8629641751]
4 sites-disposant-du-service-paris-wi-fi 76280ce4b86872e0c0696c047c1d140b66c6868f 2019-10-08T07:01:10.494000+00:00 75016 BIBLIOTHEQUE GERMAINE TILLION 6 RUE DU COMMANDANT SCHLOESING [48.8618363826, 2.28427079122] 2 PW0113 Point [2.284270791218422, 48.86183638257241] Opérationnel Point [2.28427079122, 48.8618363826]

Clean the dataframe and save lat and lon columns


In [3]:
df.columns = df.columns.str.replace(".", "_")
df[['lon','lat']] = pandas.DataFrame(df['geometry_coordinates'].values.tolist(), index=df.index)
df.head()


Out[3]:
datasetid recordid record_timestamp fields_cp fields_nom_site fields_arc_adresse fields_geo_point_2d fields_nombre_de_borne_wifi fields_idpw fields_geo_shape_type fields_geo_shape_coordinates fields_etat2 geometry_type geometry_coordinates lon lat
0 sites-disposant-du-service-paris-wi-fi 31c3bfd9ad944ec1bea07cbeb28dc6bb0653e530 2019-10-08T07:01:10.494000+00:00 75010 MEDIATHEQUE FRANCOISE SAGAN 8 RUE LEON SCHWARTZENBERG [48.8754298708, 2.35366677297] 11 PW0147 Point [2.353666772968424, 48.87542987081135] Opérationnel Point [2.35366677297, 48.8754298708] 2.353667 48.875430
1 sites-disposant-du-service-paris-wi-fi 322b5836dd2af4413728e67dc4432cf83dde06b1 2019-10-08T07:01:10.494000+00:00 75020 PARC DE BELLEVILLE (PARIS NATURE MAISON DE L'AIR) 27 RUE PIAT [48.8716051488, 2.38492475051] 1 PW0168 Point [2.384924750509342, 48.87160514880642] Opérationnel Point [2.38492475051, 48.8716051488] 2.384925 48.871605
2 sites-disposant-du-service-paris-wi-fi ec66708cf6e56caced0ae6485f68c0a44167636d 2019-10-08T07:01:10.494000+00:00 75013 JARDIN BRASSAI 59 BOULEVARD AUGUSTE BLANQUI [48.8292152156, 2.34951229427] 1 NaN Point [2.349512294267843, 48.82921521555871] En étude Point [2.34951229427, 48.8292152156] 2.349512 48.829215
3 sites-disposant-du-service-paris-wi-fi 6f37d419ab91b1d9b2972eafe2f5585c4d51f358 2019-10-08T07:01:10.494000+00:00 75007 BERGES RIVE GAUCHE - JARDIN FLOTTANT PORT DU GROS CAILLOU [48.8629641751, 2.30452468194] 3 PW0189 Point [2.30452468193794, 48.86296417505911] Opérationnel Point [2.30452468194, 48.8629641751] 2.304525 48.862964
4 sites-disposant-du-service-paris-wi-fi 76280ce4b86872e0c0696c047c1d140b66c6868f 2019-10-08T07:01:10.494000+00:00 75016 BIBLIOTHEQUE GERMAINE TILLION 6 RUE DU COMMANDANT SCHLOESING [48.8618363826, 2.28427079122] 2 PW0113 Point [2.284270791218422, 48.86183638257241] Opérationnel Point [2.28427079122, 48.8618363826] 2.284271 48.861836

Generate a GeoDataFrame using lat and lon columns


In [4]:
from geopandas import GeoDataFrame, points_from_xy

gdf = GeoDataFrame(df, geometry=points_from_xy(df['lon'], df['lat']))
gdf.head()


Out[4]:
datasetid recordid record_timestamp fields_cp fields_nom_site fields_arc_adresse fields_geo_point_2d fields_nombre_de_borne_wifi fields_idpw fields_geo_shape_type fields_geo_shape_coordinates fields_etat2 geometry_type geometry_coordinates lon lat geometry
0 sites-disposant-du-service-paris-wi-fi 31c3bfd9ad944ec1bea07cbeb28dc6bb0653e530 2019-10-08T07:01:10.494000+00:00 75010 MEDIATHEQUE FRANCOISE SAGAN 8 RUE LEON SCHWARTZENBERG [48.8754298708, 2.35366677297] 11 PW0147 Point [2.353666772968424, 48.87542987081135] Opérationnel Point [2.35366677297, 48.8754298708] 2.353667 48.875430 POINT (2.35367 48.87543)
1 sites-disposant-du-service-paris-wi-fi 322b5836dd2af4413728e67dc4432cf83dde06b1 2019-10-08T07:01:10.494000+00:00 75020 PARC DE BELLEVILLE (PARIS NATURE MAISON DE L'AIR) 27 RUE PIAT [48.8716051488, 2.38492475051] 1 PW0168 Point [2.384924750509342, 48.87160514880642] Opérationnel Point [2.38492475051, 48.8716051488] 2.384925 48.871605 POINT (2.38492 48.87161)
2 sites-disposant-du-service-paris-wi-fi ec66708cf6e56caced0ae6485f68c0a44167636d 2019-10-08T07:01:10.494000+00:00 75013 JARDIN BRASSAI 59 BOULEVARD AUGUSTE BLANQUI [48.8292152156, 2.34951229427] 1 NaN Point [2.349512294267843, 48.82921521555871] En étude Point [2.34951229427, 48.8292152156] 2.349512 48.829215 POINT (2.34951 48.82922)
3 sites-disposant-du-service-paris-wi-fi 6f37d419ab91b1d9b2972eafe2f5585c4d51f358 2019-10-08T07:01:10.494000+00:00 75007 BERGES RIVE GAUCHE - JARDIN FLOTTANT PORT DU GROS CAILLOU [48.8629641751, 2.30452468194] 3 PW0189 Point [2.30452468193794, 48.86296417505911] Opérationnel Point [2.30452468194, 48.8629641751] 2.304525 48.862964 POINT (2.30452 48.86296)
4 sites-disposant-du-service-paris-wi-fi 76280ce4b86872e0c0696c047c1d140b66c6868f 2019-10-08T07:01:10.494000+00:00 75016 BIBLIOTHEQUE GERMAINE TILLION 6 RUE DU COMMANDANT SCHLOESING [48.8618363826, 2.28427079122] 2 PW0113 Point [2.284270791218422, 48.86183638257241] Opérationnel Point [2.28427079122, 48.8618363826] 2.284271 48.861836 POINT (2.28427 48.86184)

Visualize the data


In [5]:
from cartoframes.viz import Layer, color_category_style, basic_legend

Layer(
    gdf,
    color_category_style(
        'fields_etat2', 
        palette='[green, yellow, red, silver]',
    ),
    legends=basic_legend(
        title='WiFi Services in Paris',
        footer='Source: <a href="https://opendata.paris.fr" target="_blank">Open Data Paris</a>'
    )
)


Out[5]:
Source: Open Data Paris
:
StackTrace
    ">