Introduction
Data visualization is a key component in business intelligence and analytics. While tools like Power BI and Tableau are popular, Python offers powerful open-source alternatives for building interactive dashboards and reports: Streamlit, Dash, and Bokeh. These tools allow rapid development and deployment of data apps, making them ideal for data scientists and analysts.
Streamlit
Streamlit is a Python library that makes it easy to create interactive web apps for data visualization with minimal code.
Example: Simple Dashboard
# streamlit_app.py
import streamlit as st
import pandas as pd
import numpy as np
data = pd.DataFrame(
np.random.randn(100, 3),
columns=['A', 'B', 'C']
)
st.title('Streamlit Dashboard Example')
st.line_chart(data)
Deploying to the Cloud
You can deploy Streamlit apps for free using Streamlit Cloud. Just push your code to GitHub and connect your repo in Streamlit Cloud.
Dash
Dash, developed by Plotly, is a framework for building analytical web applications with Python.
Example: Interactive Dashboard
# dash_app.py
import dash
from dash import html, dcc
import plotly.express as px
import pandas as pd
app = dash.Dash(__name__)
df = pd.DataFrame({"x": range(10), "y": [i**2 for i in range(10)]})
fig = px.line(df, x="x", y="y", title="Dash Example")
app.layout = html.Div([
html.H1("Dash Dashboard Example"),
dcc.Graph(figure=fig)
])
if __name__ == "__main__":
app.run_server(debug=True)
Deploying to the Cloud
Dash apps can be deployed on Heroku or Render. Both platforms offer free tiers for small projects.
Bokeh
Bokeh is a Python library for creating interactive visualizations for modern web browsers.
Example: Interactive Plot
# bokeh_app.py
from bokeh.plotting import figure, output_file, show
output_file("bokeh_example.html")
p = figure(title="Bokeh Line Example", x_axis_label='x', y_axis_label='y')
p.line([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], legend_label="Temp.", line_width=2)
show(p)
Deploying to the Cloud
Bokeh apps can be deployed using Bokeh Server on cloud platforms like Heroku or AWS.
Practice what you learned! ππ
Conclusion
Streamlit, Dash, and Bokeh are excellent choices for building interactive dashboards and reports in Python. They are easy to use, flexible, and can be deployed to the cloud for sharing insights with your team or the world.
Top comments (2)
Good B3
nice very nice, my nigga friend