Created
September 12, 2022 11:22
-
-
Save Abhayparashar31/7c1167014180ee920154cd19d02f6bee 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
def plot_connections_on_different_weekdays(df): | |
day_names = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] | |
df['day_name'] = pd.to_datetime(df['Connected_on']).dt.day_name() | |
data = df['day_name'].value_counts() | |
weekday_df = data.reset_index() | |
weekday_df['index'] = pd.Categorical(weekday_df['index'],categories=day_names,ordered=True) | |
weekday_df = weekday_df.sort_values('index') | |
weekday_df = weekday_df.rename(columns = { | |
"index":'week_day', | |
"day_name":"count" | |
}) | |
fig = px.bar(x = weekday_df['week_day'], y=weekday_df['count'],labels={ | |
'x':'Day', | |
'y':'Number of Connections' | |
}) | |
return fig | |
plot_connections_on_different_weekdays(df) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment