Skip to content

Instantly share code, notes, and snippets.

@heronyang
Last active January 6, 2019 08:01
Show Gist options
  • Select an option

  • Save heronyang/2ecc6c76ad59878d4984534460afb06b to your computer and use it in GitHub Desktop.

Select an option

Save heronyang/2ecc6c76ad59878d4984534460afb06b to your computer and use it in GitHub Desktop.
import pandas as pd
df_l = pd.read_csv('20180220.csv',
names=['TimeInterval', 'GantryFrom', 'GantryTo',
'VehicleType', 'SpaceMeanSpeed', '交通量'])
df_2l = pd.read_csv('20180219.csv',
names=['TimeInterval', 'GantryFrom', 'GantryTo',
'VehicleType', 'SpaceMeanSpeed', '交通量'])
def print_summary(df, field):
# import pdb;pdb.set_trace()
summary = {
"mean": df[field].mean(),
"median": df[field].median(),
"p50": df[field].quantile(0.5),
"p90": df[field].quantile(0.5)
}
print(summary)
print('last day')
print_summary(df_l, 'SpaceMeanSpeed')
print('2nd last day')
print_summary(df_2l, 'SpaceMeanSpeed')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment