Skip to content

Instantly share code, notes, and snippets.

View MaximePawlakFr's full-sized avatar

Maxime MaximePawlakFr

  • Toulouse
View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
len_lat = len(df["prec_lat"].unique())
len_lon = len(df["prec_lon"].unique())
print("Unique lat", len_lat)
print("Unique lon", len_lon)
df_villes_grouped_clean.to_csv("final_deplacements.csv")
df_villes_grouped_clean["nombre"].sum()
48754.0
df_villes_grouped_clean = df_villes_grouped["counts"].sum().reset_index()[columns_to_keep]
df_villes_grouped_clean = df_villes_grouped_clean.rename(columns={"prec_ville":"depart", "interv_ville":"arrivee","counts":"nombre"})
df_infos(df_villes_grouped_clean)
df_villes_grouped = df_villes.groupby(["prec_ville", "interv_ville"])
df_villes_grouped
df_villes = df.merge(df_final, how="left", left_on="prec_str_position", right_on="str_position")
df_villes = df_villes.merge(df_final, how="left", left_on="interv_str_position", right_on="str_position")
df_villes = df_villes.rename(columns={"ville_x":"prec_ville", "ville_y":"interv_ville"})
columns_to_keep = ["prec_ville", "interv_ville", "counts"]
df_villes[columns_to_keep].head()
# Save locally
df_final.to_pickle("./df_final.pkl")
df_final = add_geo_point(df_unique_positions)
df_infos(df_final)
import geocoder
import os
mapbox_token = os.environ['MAPBOX_TOKEN']
assert mapbox_token
from pandas import Series
def georeverse(point):
 return geocoder.mapbox(point, method='reverse',key=mapbox_token)
def get_city_and_postal(point):