Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
len_lat = len(df["prec_lat"].unique()) | |
len_lon = len(df["prec_lon"].unique()) | |
print("Unique lat", len_lat) | |
print("Unique lon", len_lon) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
df_villes_grouped_clean.to_csv("final_deplacements.csv") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
df_villes_grouped_clean["nombre"].sum() | |
48754.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
df_villes_grouped = df_villes.groupby(["prec_ville", "interv_ville"]) | |
df_villes_grouped |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Save locally | |
df_final.to_pickle("./df_final.pkl") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
df_final = add_geo_point(df_unique_positions) | |
df_infos(df_final) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
NewerOlder