<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Xander Jay Cagang</title>
    <description>The latest articles on DEV Community by Xander Jay Cagang (@xander_jaycagang_1e857fa).</description>
    <link>https://dev.to/xander_jaycagang_1e857fa</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3708681%2F352126a1-5e60-486f-9fc2-c3b28724a296.jpg</url>
      <title>DEV Community: Xander Jay Cagang</title>
      <link>https://dev.to/xander_jaycagang_1e857fa</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/xander_jaycagang_1e857fa"/>
    <language>en</language>
    <item>
      <title>A Beginner's Guide to Making Data Web Applications using Python with Streamlit</title>
      <dc:creator>Xander Jay Cagang</dc:creator>
      <pubDate>Sun, 22 Feb 2026 07:58:53 +0000</pubDate>
      <link>https://dev.to/up_min_sparcs/a-beginners-guide-to-making-data-web-applications-using-python-with-streamlit-19g5</link>
      <guid>https://dev.to/up_min_sparcs/a-beginners-guide-to-making-data-web-applications-using-python-with-streamlit-19g5</guid>
      <description>&lt;p&gt;This article is co-authored by &lt;a href="https://dev.to/jedfrromero"&gt;Jed Franz M. Romero&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;As a Python programmer, you usually work with different kinds of data most of the time. At the same time, Python developers usually work on the server side or the backend on a lot of projects. But have you ever wondered if you could share your data easily on a web application for other users to see, without needing to have frontend development skills? Let us introduce you to a Python framework that is simple and beginner-friendly: &lt;a href="https://streamlit.io/" rel="noopener noreferrer"&gt;Streamlit&lt;/a&gt;!&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Streamlit?
&lt;/h2&gt;

&lt;p&gt;Streamlit is an open-source Python framework that is used just like any Python library. It provides a way to share and display different data simply through web applications, all purely in Python. It is basically a frontend cheat code for Python developers who want to create web applications in a fast and simple way. It provides several unique functionalities, including simple writing of text, data elements, charts, input widgets, media elements, layouts and containers, chat elements, and status elements.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why use Streamlit?
&lt;/h2&gt;

&lt;p&gt;A lot of web application projects use Python for the backend with HTML and CSS or even other frontend frameworks for the frontend. However, using HTML, CSS, and other frameworks is usually difficult to use, as they have long syntaxes and can result in many lines of code. Streamlit helps developers, especially with rushed projects, to create web applications efficiently. Although it is a framework that uses Python, it can translate Python code into a web user interface. As Python can already handle different types of data, Streamlit helps share and display that data.&lt;/p&gt;

&lt;p&gt;Just like any Python library, it can easily be installed in your projects. It provides very simple syntax for its elements, just like a simple function call with several parameters to adjust its characteristics. It is simple and clean, which improves your code’s readability. It is also a very helpful playground, as changes in your code will automatically refresh your web application, whether it is running on your local machine or on your preferred deployed environment. Furthermore, Streamlit also provides free deployment of your Streamlit applications on their community cloud, which allows a lot of developers to share their data and ideas with users from all around the world.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting Started with Streamlit
&lt;/h2&gt;

&lt;p&gt;As we begin with learning all about Streamlit in Python, let us first prepare and install everything that we need for our project.&lt;/p&gt;

&lt;h3&gt;
  
  
  Prerequisites
&lt;/h3&gt;

&lt;p&gt;Before we begin, it is important to check if you have a proper setup for Streamlit to work. For this guide, make sure you have the following:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;a href="https://www.python.org/downloads/" rel="noopener noreferrer"&gt;Python 3.9 or higher&lt;/a&gt; (you can check by typing the command &lt;code&gt;python --version&lt;/code&gt; or &lt;code&gt;python3 --version&lt;/code&gt; in a terminal),&lt;/li&gt;
&lt;li&gt;a Python package manager such as pip, and&lt;/li&gt;
&lt;li&gt;a code editor of your choice.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Installation
&lt;/h3&gt;

&lt;p&gt;Before we begin, we must first create a folder or directory where we will make our project. Open any terminal and type in:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;myFirstStreamlitApp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, we must redirect our machines to our project directory, where we want Streamlit to be installed. Open any terminal and go to your project directory by typing the command below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;myFirstStreamlitApp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once in the project directory, it is recommended to create a Python virtual environment for your project in order to keep what you install inside your project, rather than globally in your computer. You can setup a virtual environment by typing the command below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python &lt;span class="nt"&gt;-m&lt;/span&gt; venv .venv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, you must activate your virtual environment with the command below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Windows Command Prompt&lt;/span&gt;
.venv&lt;span class="se"&gt;\S&lt;/span&gt;cripts&lt;span class="se"&gt;\a&lt;/span&gt;ctivate.bat

&lt;span class="c"&gt;# Windows Powershell&lt;/span&gt;
.venv&lt;span class="se"&gt;\S&lt;/span&gt;cripts&lt;span class="se"&gt;\A&lt;/span&gt;ctivate.ps1

&lt;span class="c"&gt;# macOS or Linux&lt;/span&gt;
&lt;span class="nb"&gt;source&lt;/span&gt; .venv/bin/activate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once your virtual environment is up and running, you can now install the Streamlit package by typing the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;streamlit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To test if you’ve installed it properly, run the following command to see the official Streamlit app locally:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;streamlit hello
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once a website is opened in your browser locally, you’ve completed the installation of Streamlit.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi60lspvqezfie1o3w3ka.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi60lspvqezfie1o3w3ka.png" alt="Screenshot of the opened Streamlit app after entering 'streamlit' hello" width="800" height="496"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  How to run your Streamlit app
&lt;/h3&gt;

&lt;p&gt;In order to open your Streamlit app, you must always run your virtual environment. Create a Python file &lt;code&gt;app.py&lt;/code&gt; where you will write Streamlit functions to handle your data. The following command allows you to open and test your app locally:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;streamlit run app.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will run and open your app locally in your browser (usually at &lt;code&gt;localhost:8501&lt;/code&gt;), ready for editing and sharing.&lt;/p&gt;

&lt;h3&gt;
  
  
  Import Streamlit
&lt;/h3&gt;

&lt;p&gt;In order to access Streamlit in your Python files, you will need to import it on top of the files.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;streamlit&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;st&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will allow you to use Streamlit with st with any function, just like &lt;code&gt;st.write()&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Import Data
&lt;/h3&gt;

&lt;p&gt;To follow along with the tutorial, download all of the CSV files in this &lt;a href="https://drive.google.com/drive/folders/1ozx7l6khv6JnB7ZR-7OgniWp5kP9ClwX?usp=sharing" rel="noopener noreferrer"&gt;Google Drive&lt;/a&gt;, and place them in your project folder. These files serve as our sample data which we will be using for the examples below.&lt;/p&gt;

&lt;p&gt;Once in the project folder, you can then create a dataframe from the CSV by writing the following code. &lt;em&gt;Note: To create a dataframe from a CSV file, you will need the help of &lt;a href="https://pandas.pydata.org/" rel="noopener noreferrer"&gt;pandas&lt;/a&gt;.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;pandas&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;

&lt;span class="n"&gt;preference_dataframe&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read_csv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;preference_data.csv&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;summary_matrix&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read_csv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;preference_summary.csv&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;visitor_dataframe&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read_csv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;visitor_data.csv&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;plant_dataframe&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read_csv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;plant_data.csv&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;sales_dataframe&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read_csv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;sales_data.csv&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Using Streamlit functions
&lt;/h3&gt;

&lt;p&gt;Now we are at the exciting part! Let us try to share and display different types of data using the different functions Streamlit provides.&lt;/p&gt;

&lt;p&gt;The functions allow us to create basic text elements such as &lt;code&gt;st.title()&lt;/code&gt;, &lt;code&gt;st.header()&lt;/code&gt;, and &lt;code&gt;st.text()&lt;/code&gt;, and data visualizations, some of which we will explore in the following examples.&lt;/p&gt;

&lt;h4&gt;
  
  
  Example 1: &lt;code&gt;st.dataframe()&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;We can display our imported raw data in two different ways. One of which is through the function &lt;code&gt;st.dataframe()&lt;/code&gt;, which displays your dataframe as an interactive table. This allows users to view and explore your data in various ways, such as sorting, reordering, resizing, copying, and downloading data.&lt;/p&gt;

&lt;p&gt;For this example, let us display our preference data as an interactive table. To create an interactive table, type the code below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;st&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;header&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Interactive Table&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;st&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dataframe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;preference_dataframe&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fau1dil8ru4f5gilbq2qz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fau1dil8ru4f5gilbq2qz.png" alt="Sample interactable table using st.dataframe()" width="800" height="324"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once your code is running, your browser should now display the given dataframe in an interactive table.&lt;/p&gt;

&lt;h4&gt;
  
  
  Example 2: &lt;code&gt;st.table()&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;Another way to display our raw data is using &lt;code&gt;st.table()&lt;/code&gt;. This can be used when you want to have a static table instead of an interactive table.&lt;/p&gt;

&lt;p&gt;For this example, let us try to display our sample summary report of our preference data as a static table. To create a static table, type the code below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;st&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;header&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Static Table&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;st&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;table&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;summary_matrix&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once written, your web application will display the summary report of the data through a simple and static table.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg4dh2ipdlcg4yj70xbbu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg4dh2ipdlcg4yj70xbbu.png" alt="Sample static table using st.table()" width="800" height="237"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Example 3: &lt;code&gt;st.metric()&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;If you want to present a metric or a value that is being tracked over time, we can show it using &lt;code&gt;st.metric()&lt;/code&gt;. This function lets you display a value and how much it has changed over time.&lt;/p&gt;

&lt;p&gt;In this example, let us try to show the last recorded visitor count from our visitor dataframe (obtained by using &lt;code&gt;visitor_dataframe["Count"].iloc[-1]&lt;/code&gt;) as a metric and compare its difference with the previous record (obtained by using &lt;code&gt;visitor_dataframe["Count"].iloc[-2]&lt;/code&gt;). To do this, type the code below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;last_recorded&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;visitor_dataframe&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Count&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;iloc&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;previous_recorded&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;visitor_dataframe&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Count&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;iloc&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;last_recorded&lt;/span&gt;
&lt;span class="n"&gt;delta&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;last_recorded&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;previous_recorded&lt;/span&gt;

&lt;span class="n"&gt;st&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;header&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Metric&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;st&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;metric&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Visitors&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;delta&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;border&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1iadt622cpyhyoou1h0h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1iadt622cpyhyoou1h0h.png" alt="Sample metric using st.metric()" width="800" height="167"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;st.metric()&lt;/code&gt; function takes multiple parameters. The first parameter, &lt;code&gt;label&lt;/code&gt;, describes the header of the metric. The second parameter, &lt;code&gt;value&lt;/code&gt;, describes the value of the metric. The third parameter, &lt;code&gt;delta&lt;/code&gt;, describes the amount of how much the value has changed. Other parameters help change the appearance and behaviour of the metric element, such as &lt;code&gt;label_visibility&lt;/code&gt; and &lt;code&gt;border&lt;/code&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  Example 4: &lt;code&gt;st.bar_chart()&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;A bar chart is a graphical representation to see the differences between different categories.&lt;/p&gt;

&lt;p&gt;For example, we want to see the difference in the heights of plants graphically. To do that, we will create a simple bar chart. To create one with the help of Streamlit, type the function element below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;st&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;header&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Bar Chart&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;st&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;bar_chart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;plant_dataframe&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Plant&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Height (in cm)&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once written in your code, the bar chart will show up in your web application when run. You will see a bar chart representing plant data.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu2hirkcac4tvw6rbebua.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu2hirkcac4tvw6rbebua.png" alt="Sample bar chart using st.bar_chart()" width="800" height="446"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;st.bar_chart()&lt;/code&gt; function provides several parameters to be handled. The first one defines the dataframe to be displayed. The second parameter defines the x-axis value, which is the different types of plants listed in our data. Similarly, the third parameter defines the y-axis value, which is specified as the height of the plants in centimeters. It also handles other parameters like &lt;code&gt;x_label&lt;/code&gt;, &lt;code&gt;y_label&lt;/code&gt;, &lt;code&gt;color&lt;/code&gt;, &lt;code&gt;horizontal&lt;/code&gt;, &lt;code&gt;sort&lt;/code&gt;, &lt;code&gt;stack&lt;/code&gt;, &lt;code&gt;width&lt;/code&gt;, and &lt;code&gt;height&lt;/code&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  Example 5: &lt;code&gt;st.line_chart()&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;A line chart is a graphical representation of trends or changes in data. &lt;/p&gt;

&lt;p&gt;Given the data of the monthly sales of a business, let us try to display it using a line chart to see how the sales of the business changed throughout the year. &lt;/p&gt;

&lt;p&gt;First, we should remember that different data must be handled differently. As in this case, you need to check how the month is formatted, whether it be in the format of &lt;em&gt;“Month”&lt;/em&gt; or &lt;em&gt;“Year-Month”&lt;/em&gt; as the line chart function will treat them differently. To handle these sorts of challenges, you will need to ask for help from another library such as pandas. One way to do this is to include the code below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;sales_dataframe&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Month&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;to_datetime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sales_dataframe&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Month&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="nb"&gt;format&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;%Y-%b&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;sales_dataframe&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sales_dataframe&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sort_values&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Month&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then to create a line chart, type the function below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;st&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;header&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Line Chart&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;st&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;line_chart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sales_dataframe&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Month&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Sales&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once coded, you will see the line chart in your web application.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiusmr3tw18bo6p9uvohn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiusmr3tw18bo6p9uvohn.png" alt="Sample line chart using st.line_chart()" width="800" height="411"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;st.line_chart()&lt;/code&gt; function also provides several parameters to be handled. Similarly, one parameter is the x-axis, which in this case is the months, while another parameter is the y-axis, which in this case is the sales. Other parameters also include &lt;code&gt;x_label&lt;/code&gt;, &lt;code&gt;y_label&lt;/code&gt;, &lt;code&gt;color&lt;/code&gt;, &lt;code&gt;width&lt;/code&gt;, and &lt;code&gt;height&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Congratulations! You have made your first data web app using Streamlit. Now that you have explored some of Streamlit’s features, you can further enhance your data web apps with its other features, such as creating layouts, adding media elements, using input widgets, adding pagination, caching, authentication, integrating other Python libraries and frameworks like &lt;a href="https://matplotlib.org/" rel="noopener noreferrer"&gt;matplotlib&lt;/a&gt; or &lt;a href="https://pytorch.org/" rel="noopener noreferrer"&gt;Pytorch&lt;/a&gt;, and many more. You can also start sharing your data apps by deploying your Streamlit script in your own preferred deployment environment or even in &lt;a href="https://docs.streamlit.io/deploy/streamlit-community-cloud" rel="noopener noreferrer"&gt;Streamlit Community Cloud&lt;/a&gt; for free.&lt;/p&gt;

&lt;p&gt;In case you need more inspiration as to how Streamlit can be used to make web apps, you can visit &lt;a href="https://streamlit.io/gallery" rel="noopener noreferrer"&gt;Streamlit’s app gallery&lt;/a&gt; or the &lt;a href="https://share.streamlit.io/explore" rel="noopener noreferrer"&gt;Streamlit Community Cloud&lt;/a&gt; to check other people’s projects with Streamlit. You can also check the &lt;a href="https://docs.streamlit.io/" rel="noopener noreferrer"&gt;official documentation website&lt;/a&gt; to learn more about its features and its inner workings.&lt;/p&gt;

&lt;p&gt;If you want to further explore the code snippets above, you can access the source code in its &lt;a href="https://github.com/Ostiminum/sample-streamlit-app" rel="noopener noreferrer"&gt;GitHub repository&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;You can also visit a working demo of the code on &lt;a href="https://sample-app-app-yp9dvbxejxxumyvasvlshz.streamlit.app/" rel="noopener noreferrer"&gt;this website hosted in Streamlit Community Cloud&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;References&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://streamlit.io/" rel="noopener noreferrer"&gt;https://streamlit.io/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.streamlit.io/" rel="noopener noreferrer"&gt;https://docs.streamlit.io/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>beginners</category>
      <category>python</category>
      <category>streamlit</category>
      <category>data</category>
    </item>
  </channel>
</rss>
