Python Data Visualization Transcripts
Chapter: Streamlit
Lecture: Simple app example

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Now I'm going to go through a simple example of creating a streamlit file, so we're no longer going to use a jupyter notebook for these examples.
0:09 I'm going to use VS Code but you can use any editor you want, you can use PyCharm or Sublime or even just a simple text editor.
0:18 And then I have my conda environment open to the datavis environment that I've been using for this course. I have already installed streamlit.
0:29 Using python -m pip, install streamlit. So now let's create our first file zoom in a little bit so you can see
0:38 it from a python perspective. I use path pandas and plotly express like I
0:45 have in my other notebook visualizations but I am also going to import stream lit as ST. After doing all of our standard imports.
0:55 I'm going to zoom out a little bit so you can see read in my source file using the EPA fuel economy summary, then read in my data frame.
1:06 And then my final step here is to create a histogram and to keep it simple, we're going to focus on the histogram that we have already
1:15 done in the past for the fuel cost as well as coloring it by class summary And then so the only pieces that are particular to streamlit are to add
1:25 a title and we can also now display the figure and to do that we use write ST. So what we've done is created histogram figure.
1:37 Now we're telling streamlit to show the title as simple example and to display the plotly figure. So now that I save this,
1:45 I'll go to my terminal, you can see that I have one file here. ST simple one.py which is the file I used here. And if we want to run it,
1:57 we now do streamlit. Run simple. So the command, stream lit run and you will see the URL's
2:05 now where you can actually view your application and what happens behind the scenes is streamlit
2:13 spins up this web server and now I have my histogram and I can interact with it. Like I have in plotly in the past and now I
2:24 have a web application though which we can build upon and do more customization, which I will show in a moment.


Talk Python's Mastodon Michael Kennedy's Mastodon