Skip to content

Instantly share code, notes, and snippets.

@gumdropsteve
Created October 1, 2020 06:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gumdropsteve/b3e9dde7584a53facb472774c4570688 to your computer and use it in GitHub Desktop.
Save gumdropsteve/b3e9dde7584a53facb472774c4570688 to your computer and use it in GitHub Desktop.
# convert ds to datetime and average trip distance to float
df['ds'] = pd.to_datetime(df['ds'])
df['avg_trip_distance'] = df['avg_trip_distance'].astype('float')
# remove erroneous averages
df = df.loc[df['avg_trip_distance'] < 5]
# relabel average trip distance as y
df = df.rename(columns={'avg_trip_distance' : 'y'})
# plot the average trip distance by day
df.plot(x='ds', y='y', figsize=(16, 4), title='Average Trip Distance (Miles) - NYC Yellow Cab', )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment