{ "metadata": { "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.5-final" }, "orig_nbformat": 2, "kernelspec": { "name": "python_defaultSpec_1601889646686", "display_name": "Python 3.8.5 64-bit ('streamlit': conda)", "metadata": { "interpreter": { "hash": "d5b47a323bfc67f94a37e7cb8fd52db1ad06cc55d227a5b8c375f2f5af6e26dc" } } } }, "nbformat": 4, "nbformat_minor": 2, "cells": [ { "source": [ "# A first view on Streamlit" ], "cell_type": "markdown", "metadata": {} }, { "source": [ "I had a look into streamlit as anoter way to deploy a data science app. It seems really convenient to work with.\n", "\n", "Unfortunately, I cannot use it on a static website, so I need to learn how to deploy it on a service with Docker." ], "cell_type": "markdown", "metadata": {} }, { "source": [ "## Tutorial" ], "cell_type": "markdown", "metadata": {} }, { "source": [ "I went through the [getting started tutorial](https://docs.streamlit.io/en/stable/getting_started.html), below are the main steps." ], "cell_type": "markdown", "metadata": {} }, { "source": [ "We import streamlit as a separate package and simply run it in as script. \n", "\n", "```shell\n", "streamlit run first_app.py\n", "```\n", "\n", "This, by default, creates a local server where we can see the results." ], "cell_type": "markdown", "metadata": {} }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import streamlit as st\n", "\n", "import numpy as np\n", "import pandas as pd\n", "import altair as alt" ] }, { "source": [ "Streamlit tries to diplay everything, somehow similar how it happens in a jupyter notebook." ], "cell_type": "markdown", "metadata": {} }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": " first second\n0 1 10\n1 2 20\n2 3 30\n3 4 40", "text/html": "
\n | first | \nsecond | \n
---|---|---|
0 | \n1 | \n10 | \n
1 | \n2 | \n20 | \n
2 | \n3 | \n30 | \n
3 | \n4 | \n40 | \n