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
>>> teams_contacted_df.head() | |
team contacted date con_from deg_sep | |
21 SACRAMENTO_KINGS True 2020-03-10 SACRAMENTO_KINGS 0 | |
18 NEW_ORLEANS_PELICANS True 2020-03-11 SACRAMENTO_KINGS 1 | |
10 UTAH_JAZZ True 2020-03-13 NEW_ORLEANS_PELICANS 2 | |
1 LOS_ANGELES_CLIPPERS True 2020-03-14 NEW_ORLEANS_PELICANS 2 | |
17 MEMPHIS_GRIZZLIES True 2020-03-14 UTAH_JAZZ 3 |
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
teams_contacted_df = teams_contacted_df.assign(orig_lat=0, orig_lon=0, dest_lat=0, dest_lon=0) | |
for temp_tuple in teams_contacted_df.itertuples(): | |
if temp_tuple.con_from == None: | |
from_name = temp_tuple.team | |
else: | |
from_name = temp_tuple.con_from | |
teams_contacted_df.loc[temp_tuple.Index, 'orig_lat'] = arena_df[arena_df.teamupper == from_name]['lat'].values[0] | |
teams_contacted_df.loc[temp_tuple.Index, 'orig_lon'] = arena_df[arena_df.teamupper == from_name]['lon'].values[0] | |
teams_contacted_df.loc[temp_tuple.Index, 'dest_lat'] = arena_df[arena_df.teamupper == temp_tuple.team]['lat'].values[0] |
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
# Initialise figure | |
fig = go.Figure() | |
# Add arenas | |
fig.add_trace(go.Scattergeo( | |
lon=arena_df['lon'], lat=arena_df['lat'], marker=dict(size=8, color='slategray'), | |
hoverinfo='text', text=arena_df['teamname'] + ' - ' + arena_df['arena_name'], name='Arenas' | |
)) | |
for i in range(len(teams_contacted_df)): |
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
fig['data'][0]['marker']['symbol'] = 'triangle-left' | |
fig.update_layout( | |
title_text="NBA Teams' degrees of separation:" | |
+ "<BR>Starting with the " + seed_tm + " on " + seed_date | |
+ ", all teams are connected within " + str(date_range.days) + " days.", | |
geo=dict( | |
scope='north america', | |
projection_type='azimuthal equal area', | |
showland=True, |
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
fig = px.histogram(comps_grpby, title='Histogram - complain counts by company', | |
x='Complaints', template='plotly_white', nbins=20) | |
fig.update_xaxes(categoryorder='total descending') | |
fig.update_yaxes(title='Number of companies') | |
fig.show() |
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
fig = px.histogram(top_comps_df, x='Company', template='plotly_white', title='Complaint counts by company') | |
fig.update_xaxes(categoryorder='total descending').update_yaxes(title='Number of complaints') | |
fig.show() |
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
fig = px.histogram(comp_df, x='datetime', template='plotly_white', title='Complaint counts by date') | |
fig.update_xaxes(categoryorder='category descending', title='Date').update_yaxes(title='Number of complaints') | |
fig.show() |
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
fig = px.histogram(comp_df, x='Words_clipped', template='plotly_white', title='Complain counts by length') | |
fig.update_xaxes(categoryorder='total descending', title='Number of words (clipped at 1000 words)').update_yaxes(title='Number of complaints') | |
fig.show() |
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
# Complaints by company & date | |
fig = px.histogram(top_comps_df, x='datetime', template='plotly_white', title='Complaint counts by date' | |
, color='Company', nbins=6, log_y=True, barmode='group') | |
fig.update_xaxes(categoryorder='category descending', title='Date').update_yaxes(title='Number of complaints') | |
fig.show() |
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
fig = px.treemap(top_comps_df, title='Treemap chart by companies and whether complaint mentions credit report.', | |
path=['Company', 'credit_report'], color='Words', color_continuous_scale=px.colors.sequential.GnBu) | |
fig.show() |