Streamlit

3 min read

Disclaimer: Before I begin, I should point out I'm NOT working for Streamlit (opens in a new tab). I'm just a lazy developer (if I could describe myself as such), who has just become addicted with this tool.

If you use Python for data visualization purposes, you might already know Plot.ly (opens in a new tab), one of the most used interactive graphic modules available both in R and Python. If that's the case, you also may have visited its website and heard about Dash (opens in a new tab), an interactive web dashboard building tool made by them.

That someone was me. Although I've never used Plot.ly yet (even until now), I've visited the site several times and spotted their ad for Dash every time I do.

In one sense, that looked cool, I could develop web applications without knowing Javascript or related technologies, including React, D3 among others. But I wasn't desperate or inclined to make one at the time. It looked great that I could create a dynamic web application, but I had nothing in my mind.

Some months later, after I had decent amount of time with ggplot, I finally felt I wanted to dive into that area. Dash was my first choice, as it was my only known option and it was available on R, so I might use ggplot on it, which was proved later, or at least not easy.

But, after I happened to see an article of comparing Streamlit and Dash, I knew it was the One except some caveats.

Weak points were its availability only on Python without conda installations. The latter was quite shocking given that I'd never seen any modules which required to used pip only. On top of that, even if it would enable users to install via conda, the developers clearly mentioned that virtual environments are STRONGLY recommended.

However, these drawbacks were comfortably eclipsed by how smart this program was. Simplicity, modern feel, and flexibility.

First, you don't have to write HTML codes or even follow some pseudo-like HTML codes. To write a text, one line is enough.

Source: Streamlit GitHub (opens in a new tab).

import streamlit as st
 
x = st.slider('Select a value')
st.write(x, 'squared is', x * x)

st.write

In fact, this is referred as magic tool in Streamlit. It can be used to display DataFrame, show charts, maps, etc.

This is the core philosophy of Streamlit. No nitty-gritty of HTML structure. While I've never had an aversion to HTML, this core concept was so appealing. Even without serious style adjustments, the default style looked so modern - to my especial liking. On the plus side, I discovered after some research, I would be given handful of options in terms of charts.

I could even use Plotnine (opens in a new tab), a ggplot module for Python, which has more than 80% of the original, while I'm afraid that the performance isn't par to default options including Altair (opens in a new tab), the graphic module which Streamlit is based on.

While I've never used them before, but I could say that the default modules Streamlit is based on are quite powerful and feauture-rich, namely, Altair and Pydeck (opens in a new tab).

The latter one is currently the reason why I became so addicted to Streamlit. Despite its lack of support for geopandas or adding legends, numerous options to draw maps including Choropleth were quite mind-blowing. With its multi-layer, I had no problems to overlay multiple measures in one map, i.e., Choropleth with depths.

Pydeck

CC BY-NC 4.0 © min park.RSS