A Python Shiny web application for analyzing loan data with interactive visualizations and state-level statistics.
This dashboard features an LLM chat sidebar powered by querychat that allows the viewer to ask questions to dynamically generate SQL sent to Snowflake using ibis and SQLAlchemy to find results.
This dashboard provides an interactive interface to explore and analyze Lending Club loan data. It features:
- Natural Language Filtering: Filter using natural language, right in the sidebar!
- Overview Analytics: Key metrics including total loans, average interest rates, and loan distributions
- State Analysis: Geographic analysis of loan patterns across US states
- Detailed Data Views: Comprehensive loan data tables with filtering capabilities
- Key Metrics: Total loans, average interest rate, and total loan amount
- Loan Amount Distribution: Histogram showing the distribution of loan amounts
- Loan Status Distribution: Pie chart showing the breakdown of loan statuses
- Average Loan Amount by State: Bar chart showing top 15 states by average loan amount
- Loan Count by State: Bar chart showing top 15 states by number of loans
- State Statistics Table: Detailed statistics for all states including averages and totals
- Filterable Data Table: Complete loan dataset with interactive filtering
- Export Capabilities: View and analyze individual loan records
Use the querychat sidebar to filter data, or get summary statistics!
- Setup the
venvenvironment:
Using uv (recommended), installer available at Installing uv:
uv venv
. .venv/bin/activate
uv pip install -r requirements.txtUsing the regular venv:
python -m venv .venv
. .venv/bin/activate
pip install -r requirements.txt- Ensure you have access to the following table in Snowflake
LENDING_CLUB.PUBLIC.LOAN_DATAunder theduloftf-posit-software-pbc-devaccount. - Run on Posit Workbench with Snowflake managed credentials or deploy on Posit Connect with Snowflake OAuth activated.
shiny-python-querychat/
├── app.py # Main Shiny application
├── pyproject.toml # Project configuration and dependencies
├── requirements.txt # Pinned dependencies for Posit Connect deployment
├── uv.lock # Locked dependency versions
├── data_dictionary.md # Data field descriptions
├── greeting.md # Welcome documentation
└── README.md # This file
The application uses the Lending Club dataset from Plotly's public datasets:
https://raw.githubusercontent.com/plotly/datasets/master/loan_data.csv
- Start with Overview: Begin by exploring the overview tab to understand the overall loan portfolio
- Apply Filters: Use the sidebar filters to focus on specific loan segments
- State Analysis: Examine geographic patterns in the State Analysis tab
- Detailed Exploration: Use the Loan Details tab for granular data analysis
- Interactive Elements: All charts and tables update automatically when filters are changed