Created
September 7, 2020 16:06
-
-
Save tanpengshi/6d07e958ee509e9b92c853c155886f7e to your computer and use it in GitHub Desktop.
Creating Heatmap 1
This file contains 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
df_10 = df[df['STATION'].isin(list(group_station.head(10).index))] | |
df_10['WEEKDAY'] = df_10['DATE'].dt.day_name() | |
group_station_day = df_10.groupby(['STATION','WEEKDAY'])['ENTRY_EXIT'].sum() | |
matrix_station_day = group_station_day.unstack() | |
matrix_station_day.reset_index() | |
matrix_station_day = matrix_station_day.reindex(columns=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]) | |
matrix_station_day = matrix_station_day.reindex(index=list(group_station.head(10).index)) | |
array = np.array(matrix_station_day.applymap(lambda x:str(round(x/1000,1))+'k')) | |
fig2 = plt.figure(figsize=[10,10]) | |
cmap = sns.cubehelix_palette(light=1, as_cmap=True) | |
ax2 = sns.heatmap(matrix_station_day,cmap='Blues',linecolor='white',linewidths=1,annot = array,fmt='') | |
plt.xlabel('Day of the Week',fontsize=15) | |
plt.ylabel('Top 10 Stations',fontsize=15) | |
plt.title('Station Traffic in the Week',weight='bold',fontsize=15) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment