Skip to content

Commit

Permalink
continue moving fx to utils
Browse files Browse the repository at this point in the history
  • Loading branch information
natam1 committed May 31, 2024
1 parent c3c2fb8 commit 0795ab3
Show file tree
Hide file tree
Showing 2 changed files with 662 additions and 786 deletions.
22 changes: 22 additions & 0 deletions sb125_analyses/corridor_study/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,28 @@ def get_unique_agencies(agency_list):

return df

def get_agencies_occurances(df):

##get list of columns that have agency names
columns_to_keep = list(df.columns.values)

## remove columns that are not agency names
unwanted_cols = {'transit_agency', 'unique_agencies', 'primary_mode', 'transit_submode', 'n', 'agency_count', 'n_modes_taken' }
columns_to_keep = [e for e in columns_to_keep if e not in unwanted_cols]

df_agencies = df.loc[:, columns_to_keep]

## transpose the df again
df_agencies = pd.DataFrame(df_agencies).transpose().reset_index().rename(columns={'index':'agency'})

##sum up the number of trips by agency
df_agencies['n_trips'] = df_agencies[list(df_agencies.columns)].sum(axis=1)

## filter df to only have two cols
df_agencies = df_agencies>>select(_.agency, _.n_trips)

return df_agencies

"""
Streetlight Analysis Utils
"""
Expand Down
Loading

0 comments on commit 0795ab3

Please sign in to comment.