Py.Cafe

Application Status Analysis

DocsPricing
  • app.py
  • requirements.txt
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# https://github.com/plotly/Figure-Friday/blob/main/2025/week-19/TLC_New_Driver_Application.csv
# https://community.plotly.com/t/figure-friday-2025-week-19/92200

# check out https://dash.plotly.com/ for documentation
# And check out https://py.cafe/maartenbreddels for more examples
from dash import Dash, dcc, html
import dash_ag_grid as dag
import plotly.express as px
import pandas as pd


df = pd.read_csv("https://raw.githubusercontent.com/plotly/Figure-Friday/refs/heads/main/2025/week-19/TLC_New_Driver_Application.csv")
# Convert 'App Date' to datetime format
df['App Date'] = pd.to_datetime(df['App Date'])

# Add week and month columns for grouping
df['Month'] = df['App Date'].dt.strftime('%B %Y')
df['Week'] = df['App Date'].dt.strftime('%U-%Y')  # Week number-Year
df['Week_label'] = 'Week ' + df['App Date'].dt.strftime('%U, %Y')  # For better readability

# Group by month and status, then count
monthly_counts = df.groupby(['Month', 'Status']).size().reset_index(name='Count')

# Create the bar chart
fig = px.bar(
    monthly_counts,
    x='Month',
    y='Count',
    color='Status',
    title='Status Counts by Month',
    labels={'Count': 'Number of Applications', 'Month': 'Month', 'Status': 'Application Status'},
    barmode='group'  # Grouped bars
)

grid = dag.AgGrid(
    rowData=df.to_dict("records"),
    columnDefs=[{"field": i, 'filter': True, 'sortable': True} for i in df.columns],
    dashGridOptions={"pagination": True},
    columnSize="sizeToFit"
)


app = Dash(__name__)

app.layout = html.Div(
    children=[
    grid,
    dcc.Graph(figure=fig)
    ]
)