# check out https://dash.plotly.com/ for documentation
# And check out https://py.cafe/maartenbreddels for more examples
from dash import Dash, Input, Output, callback, dcc, html
import plotly.express as px
import pandas as pd
df = pd.read_csv("311_Animals_short.csv")
df['Created Date'] = pd.to_datetime(df['Created Date'])
df['Closed Date'] = pd.to_datetime(df['Closed Date'])
df['Resolution Action Updated Date'] = pd.to_datetime(df['Resolution Action Updated Date'])
df['month_int'] = df['Created Date'].dt.month
df['week'] = df['Created Date'].dt.isocalendar().week
df.sort_values(by='Created Date')
df['weekofmonth'] = df['Created Date'].apply(lambda d: (d.day-1) // 7 + 1)
df['day'] = df['Created Date'].dt.dayofweek.map({
0: 'Monday',
1: 'Tuesday',
2: 'Wednesday',
3: 'Thursday',
4: 'Friday',
5: 'Saturday',
6: 'Sunday'
})
df['month_name'] = df['Created Date'].dt.month_name()
fig = px.histogram(df, x="month_name", category_orders = dict(month_name=['January', 'February', 'March']), labels = {'month_name':'MONTH'}, text_auto=True)
fig.show()
app = Dash(__name__)
md = """
# Dash demo
See [The dash examples index](https://dash-example-index.herokuapp.com/) for more examples.
"""
app.layout = html.Div(
children=[
#dcc.Markdown(children=md, link_target="_blank"),
#dcc.Dropdown(id="dropdown", options=["red", "green", "blue", "orange"]),
#dcc.Markdown(id="markdown", children=["## Hello World"]),
dcc.Graph(figure=fig),
]
)
@callback(
Output("markdown", "style"),
Input("dropdown", "value"),
)
def update_markdown_style(color):
return {"color": color}