Last active
October 7, 2022 15:28
-
-
Save jdegene/aa6a64a692efcd34b1cdaaeb922eac28 to your computer and use it in GitHub Desktop.
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
# -*- coding: utf-8 -*- | |
# 1.0 Imports | |
import dash | |
from dash import dcc | |
from dash import html | |
from dash.dependencies import Output | |
from dash.dependencies import Input | |
import plotly.express as px | |
import dash_bootstrap_components as dbc | |
import os | |
import pandas as pd | |
import random | |
# 1.1 Read in data | |
data_fol = "assets/data/" | |
wc_date_df = pd.read_csv(data_fol + "date_df.csv", sep=",", encoding="utf8") | |
wc_month_df = pd.read_csv(data_fol + "month_df.csv", sep=",", encoding="utf8") | |
wc_year_df = pd.read_csv(data_fol + "year_df.csv", sep=",", encoding="utf8") | |
# get a df sorted by word count. Is useful to only to this once here and | |
# reuse below whenever eg. only 1000 words are necesary | |
wc_date_df["word_len"] = wc_date_df["word"].str.len() | |
words = wc_date_df.groupby(["word", "word_len"] | |
)["word_cnt_page"].sum().reset_index().sort_values( | |
["word_len", "word"], ascending=True)["word"] | |
# 1.2 load external / dbc stylesheets. Not necessary but its an option | |
external_stylesheets = [ | |
{ "href": "https://fonts.googleapis.com/css2?" | |
"family=Lato:wght@400;700&display=swap", | |
"rel": "stylesheet", | |
}, | |
dbc.themes.BOOTSTRAP | |
] | |
# 1.3 initiate the app | |
app = dash.Dash(__name__, | |
external_stylesheets=external_stylesheets, | |
suppress_callback_exceptions=True, # sometimes callbacks dont work which is intended behaviour. | |
#This suppresses those notifications | |
) | |
app.title = "My Dashboard!" # name to be dislplayed eg in browser tab |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment