Last active
September 28, 2019 18:01
-
-
Save vanessaaleung/1cdf852df3035fac0aefca862170de9d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
num_top_venues = 10 | |
indicators = ['st', 'nd', 'rd'] | |
# create columns according to number of top venues | |
columns = ['Neighborhood'] | |
for ind in np.arange(num_top_venues): | |
try: | |
# append 'st', 'nd', 'rd' to the top 3 venues | |
columns.append('{}{} Most Common Venue'.format(ind + 1, indicators[ind])) | |
except: | |
columns.append('{}th Most Common Venue'.format(ind + 1)) | |
# create a new dataframe | |
neighborhoods_venues_sorted = pd.DataFrame(columns = columns) | |
neighborhoods_venues_sorted['Neighborhood'] = sf_grouped['Neighborhood'] | |
for ind in np.arange(sf_grouped.shape[0]): | |
neighborhoods_venues_sorted.iloc[ind, 1:] = return_most_common_venues(sf_grouped.iloc[ind, :], num_top_venues) | |
neighborhoods_venues_sorted.head() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment