Skip to content

Instantly share code, notes, and snippets.

@dottyz
Created May 2, 2019 18:32
Show Gist options
  • Save dottyz/a2548cc337c5cd44ec8afd08afd9050a to your computer and use it in GitHub Desktop.
Save dottyz/a2548cc337c5cd44ec8afd08afd9050a to your computer and use it in GitHub Desktop.
stations = pd.concat([stations[~stations['station_id'].isnull()], no_ids])\
.merge(bikeshare_stations[['station_id', 'lat', 'lon']], how='inner', on='station_id')\
.drop_duplicates()
df = df.merge(stations, how='inner', left_on='from_station_name', right_on='name') \
.merge(stations, how='inner', left_on='to_station_name', right_on='name', suffixes=['_from', '_to']) \
.drop_duplicates()
df = df[[x for x in df.columns if not x.endswith('_station_id') and not x.endswith('_station_name') and x != 'trip_stop_time']]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment