Podcast Lookup

Dashboards in Python with Streamlit

The Python Show

  • July 5, 2024
  • 28 min
Episode page
About this episodeThis week, I chatted with Channin Nantasenamat about Python and the Streamlit web framework. Specifically, we chatted about the following…

This week, I chatted with Channin Nantasenamat about Python and the Streamlit web framework.

Specifically, we chatted about the following topics:

* Python packages

* Streamlit

* Teaching bioinformatics

* Differences in data science disciplines

* Being a YouTuber

* and much more!

Links

* Data Professor YouTube Channel

* Follow Channin on X / Twitter

* Streamlit



Get full access to The Python Show at www.pythonshow.com/subscribe

Transcript

From the publisher

This transcript comes from the podcast’s own feed, shown as the publisher wrote it.

Dashboards in Python with Streamlit

00:00—
  1. Speaker 4

    Welcome to a brand new episode.

  2. Speaker 1

    Mike Driscoll, The Python Show.

  3. Speaker 4

    Hello, and welcome to The Python Show. I'm your host, Mike Driscoll. So anyway, my friend Chenin is on the show. He's from Thailand and used to be a professor of bioinformatics, but now works for Streamlit. Anyway, thanks so much for being on the show.

  4. Speaker 3

    Yeah, my big pleasure.

  5. Speaker 4

    And I'd like to start out our talk by just talking about your journey into programming. So if you could kick it off and let us know.

  6. Speaker 3

    Yeah, so my journey into programming was probably back in university. It was during the summer. And I was looking into creating a website. So the first language that I was exposed to was HTML. And then afterwards I was looking to see language, bought a book, a couple of books, also dabbled into Java as well. Both languages didn't really click with me. And then I sort of picked up Python after I got my PhD. I was teaching for about two years and one of my research assistants introduced me to Python. And then, yeah, so I kind of got interested in the remarkable capabilities of coding and kind of take a deeper dive there.

  7. Speaker 4

    So you started out being like a scientist first? Is that what happened when you moved to coding?

  8. Speaker 3

    Yeah, exactly. So originally I got my undergraduate and pre-med education Um, at first I thought I was going to go into med school. Um, but then like, uh, kind of changed my mind. Um, so I did a paper in medical technology. So my, my research thesis was on machine learning and also quantum mechanics. Um, it was back when they called data science more into like data mining. Um, and AI wasn't really a big thing at the time. Yeah. So it was mostly like data mining, uh, and how we applied that to biomedical data.

  9. Speaker 4

    Okay. Yeah, I hear the term bioinformatics, but I don't know much about it. Could you explain what that is?

  10. Speaker 3

    Yeah, sure. So bioinformatics is kind of like at the interface of using informatics or coding or computer science, uh, biological problems. So, I mean, there are many, um, fields at this intersection. Like if you're applying it to three, then they call it chem informatics. Um, yeah. So, so something like that.

  11. Speaker 4

    Hmm. So that's just like you apply data learning or, man, I'm really bad with my terms, machine learning models on medical problems like x-rays or stuff like that? Or is it something completely different?

  12. Speaker 3

    Yeah, so if you're applying it to x-ray, then I guess it would be more into biomedical informatics.

  13. Speaker 4

    OK.

  14. Speaker 3

    Yeah, so bioinformatics is more like DNA, RNA, protein. OK.

  15. Speaker 4

    So more like the molecular level?

  16. Speaker 3

    Molecular level, yeah, exactly.

  17. Speaker 4

    Gotcha. Interesting. I knew I learned something talking to you about stuff I know little about. And so then you moved on to work for Streamlit. Could you just tell me a little bit about what Streamlit is?

  18. Speaker 3

    Yeah, sure. So fast forward 15 years when I was in academia. So it was late 2021. I reached out to Streamlit, talked to the CAO, Adrian at the time. We had some chats. And then after that, I sort of joined the community team as a developer advocate.

  19. Speaker 4

    Nice. So what is Streamlit? I know what it is, but I don't know that our listeners will.

  20. Speaker 3

    Right. Yeah, so you could think of Serumlet as kind of like a Python library that allows you to build web applications in pure Python fairly easily.

  21. Speaker 4

    So is that like Anvil or Django?

  22. Speaker 3

    Yeah, exactly. So it's in the same niche as Django, Flask, Shiny.

  23. Speaker 4

    I wasn't sure if it was a full-fledged framework or if it was more like Dash for creating a dashboard.

  24. Speaker 3

    Yeah, so that's a good question. So, I mean, you could start off with a simple data app or web app, like general purpose application. It has React, JavaScript baked in. And so, yeah, it's kind of like you could focus more into the problem solving. And in terms of the aesthetic, there's already... built-in functions for that. I mean, they already have it ready for you to go. So you don't really have to think much about that. But if you would like to customize it, there are ways for you to modify the template, add your custom branding to it. Yeah, so that's totally fine.

  25. Speaker 4

    I'm curious, does Streamlit have the whole batteries included? Does it have a database ORM type thing or security or like an admin interface built in or anything like that?

  26. Speaker 3

    Yeah, that's a good question. So, I mean, if you think of Streamlit, it's more like a Python library. So all of the batteries are, I mean, if Python can do it, you could also implement it in a Streamlit app. So it's compatible with practically all of the entire Python ecosystem.

  27. Speaker 4

    Okay. Okay. So, yeah, I was just thinking like some of them come with stuff. Like Django comes with its own Django ORM to interface with the database. Whereas Flask, you can add on SQL Alchemy or SQL ORM or the Pony ORM, for example.

  28. Speaker 3

    Right. Yeah, definitely. Streamlit has the st.connection, which allows you to interface with several of the major databases. There's actually a page on the documentation that provides how to do it.

  29. Speaker 4

    Nice. So outside of Streamlit, what do you think are your favorite Python packages?

  30. Speaker 3

    Yeah, so I guess it's really more into what problem I would like to solve or how am I approaching the project. So if it's data science, You know, we can't miss pandas for data wrangling when we are working with tabular data sets. NumPy, especially when you want to do some numerical processing. Yeah, like Matplotlib, Plotly, Altair. I'm starting to use more Altair lately. I think it looks very crisp. And yeah, I guess... scikit-learn for building machine learning models.

  31. Speaker 4

    That makes sense.

  32. Speaker 3

    Yeah. And I really like to build dashboards as well. So I have a couple of tutorial videos on YouTube, on my YouTube channel, where I go into detail, like how to build a dashboard and also how to customize some of the visual aspect of that.

  33. Speaker 4

    That's cool. I'll definitely include your YouTube channel in my show notes, because that kind of thing is always nice to learn about. I don't think I've ever tried Altair. Is that a plotting library that lets you actually export the plots as like a PNG or SVG or anything like that?

  34. Speaker 3

    Yeah, yeah, yeah. So Altair is quite similar to Matplotlib or Plotly. So it does allow you to export it out as an image file. There's also an interactive charts output where you could zoom in, zoom out. And it looks very, I think it's vector. So the image is very super clear there.

  35. Speaker 4

    Oh, nice.

  36. Speaker 3

    So it doesn't pixelate. So yeah, that's super cool.

  37. Speaker 4

    That is cool. I think when Plotly first came out, it didn't have a way to export. And it kind of drove me nuts trying to, you know, basically, I'd take a screenshot of my graph if I wanted my own image or something. I think they fixed that sense. But there for a while, you're kind of stuck. Anyway, so let's say you didn't want to do something online or data science-y. What else would you choose for like a regular Python session?

  38. Speaker 3

    Yeah, so actually, I've also used or other Python libraries for my content creation and as well. There are some libraries that allows me to remove the dead silence in the video. Oh, nice. It'll do the jump cut for you.

  39. Speaker 2

    Like,

  40. Speaker 3

    it'll detect, like, which portion of the video has, like, silence, and then it'll jump cut, remove that portion, and kind of, like, add a small spacer to it. So I made, like, a Streamlit interface that allows you to just upload the data, I mean, upload the video file, and then it'll do the processing. Okay. On the sidebar, there's widgets for you to adjust the parameters, like how much do you want the white space between the chopped segment of the video to be. And then it exported out as a Adobe Premiere Pro file. And then I'll just import there. And then it'll save me time for the initial jump cuts, so maybe an hour or so.

  41. Speaker 4

    That's nice. I've heard of those tools, but I've never actually tried one. That's cool. Have you tried Descript? I think that's a tool I play with.

  42. Speaker 3

    Yeah, exactly. So that was way before Descript was available. And yeah, Descript is very powerful. And lately, even on the phone, there's a lot of cool captions where it'll add one of those, what do you call it, word-by-word caption to videos. So I've been experimenting with using that. I think one is Caption. I think it's called Caption on the iPhone. Okay. And yeah, super convenient.

  43. Speaker 4

    Yeah, I used the free version of Descript to edit a video once, and I was like, this is really cool. It makes it easy to cut out the stuff that I made a mistake in.

  44. Speaker 3

    Right, like text-based editing, right?

  45. Speaker 4

    Yeah, you just edit your transcript, and it'll cut out the video that's associated with it.

  46. Speaker 3

    Right, yeah. I'm also thinking of using large language models to also help in the content creation side as well. I've seen some of my friends, like Tony at work, he's also using large language models. agents to kind of like do tasks for him kind of like scrape all of the youtube comments from from a particular video summarize the comments figure out which direction should we create contents on and you know kind of like having a team but then you you kind of like define a persona for your team members one could be you know comments one could analyze it the other could act as kind of like a content marketer, kind of like to figure out which sort of content to create. And maybe another could be like a script writer to help create the actual script for the video. Yeah, so it's an interesting era and also an area to explore.

  47. Speaker 4

    Yeah, there's so much information to learn about that kind of thing. It's kind of overwhelming.

  48. Speaker 3

    Right, yeah. I mean, things are evolving so rapidly.

  49. Speaker 4

    Yeah. So we mentioned that you used to teach as a professor of bioinformatics. What sorts of things, what were major topics you had to cover as a professor?

  50. Speaker 3

    Yeah, so initially during the early years, I kind of taught microbiology lab. So it's not really into data-related topics. And then sort of afterwards, I kind of got the vibe of microbiology, kind of developed some tools in Python to simulate biochemical tests, kind of like when you go to the lab as a lab technician. You want to identify what is the bacterial species. And so what you do is you kind of subject the bacteria to various chemicals. The bacteria will kind of interact with the chemical, cause some color changes to it. If it changes purple, then we know, okay, it's purple. it's reacting to this. If it's not changing color, it's not reacting to it. And so yeah, I kind of used Python to simulate that on a bigger scale and published a paper about it. And it kind of allowed either researchers or students to to see like which combination of chemical tests are instrumental for identifying the bacterial species. And afterwards, I also applied machine learning into drug discovery, and like figure out why are certain drugs, you know, like toxic, how we can modify it so that it would be less toxic, how we can modify it so that it'll have a quicker action in regards to the activity that it is supposed to have on the human body once you adjust it. And yeah, mostly into the computational drug discovery part. like machine learning models, and lately building web applications, interactive web applications, where biochemists, chemists, biologists could provide their input data, and then they can make a prediction. So the only requirement is they have the data. So they no longer are required to know coding to actually use the model, which is a game changer in the field of the life sciences as a whole.

  51. Speaker 4

    Yeah, that makes sense. Did you ever have to create your own algorithms for your classes or anything? Or did you teach anything about creating algorithms?

  52. Speaker 3

    Well, only in the holistic sense, because most of the students are actually beginners to coding. They have no prior exposure to it. So I did some introductory lessons on how to get started in Python and how they could apply it to medicine. Um, and so, yeah, so I would provide some, you know, like basic concepts of algorithms more into kind of like cooking recipes and, um, how they could view it as, as such, like how they could be like, you know, each part of the algorithm to be kind of like a processes, um, that they're

  53. Speaker 4

    That makes sense. One of these days I need to find someone who can explain the whole process of like getting, how do you create the algorithm that can detect like a face in a video or something? I don't know that I'd understand it, but it sounds really interesting to me how that, how that all works. But that sounds really cool too. I like teaching beginners myself and while I don't, I wouldn't teach them anything about biology, teaching them Python's a lot of fun. So anyway, let's pivot and talk about how you ended up becoming a YouTuber. Mm-hmm.

  54. Speaker 3

    Right, yeah. So it was in 2019 when I first published the first video on YouTube. So back at the time, yeah, I was still teaching at university. So the first video I recorded at about like maybe 11 p.m. or so, like approaching midnight. It was like everyone was asleep, super quiet. I was kind of like... you know, like a bit hesitant to record the video. I'm not really sure why am I recording the video, but then like, it's kind of like an experiment kind of like to see what it would be like to, you know, like teach to a wider audience because normally I would, you know, just teach at a, you know, at a local classroom, like maybe a class of 30 people to 50 people.

  55. Speaker 4

    That makes sense. So how popular is your web is? Was it the people like your video or.

  56. Speaker 3

    Yeah. So, you know, like the first month or two, it was a bit quiet. Um, there were only, there were a handful of people, like maybe a hundred people or so. Um, it sort of picked up when I. you know, like collaborated with other YouTubers.

  57. Speaker 2

    Okay.

  58. Speaker 3

    Yeah. There was Ken G. He was kind of like the OG of data YouTuber. Okay. And yeah, so that kind of led me to kind of like have a buddy, you know, like a friend who's into content creation as well. And kind of, you know, like, Yeah, kind of give accountability to continue creating more content. And yeah, it kind of grew from there. The more content I created, more people come to watch. And then we did more collaboration with other data YouTuber, some of which have already grown to almost a million subscribers already. I think that was Chris Naik, also a data YouTuber. Deval from Code Basics, also another data YouTuber as well. We did a podcast there. I think the channel kind of grew by 1,000 or two to three times more. So I think I reached 5,000 subscribers because of those collaborations. And then I made a YouTube tutorial video on the Free Code Camp YouTube channel. That kind of catapulted the channel to 10,000 subscribers.

  59. Speaker 2

    Um,

  60. Speaker 3

    yeah, so it's kind of like more collaborations with other channels kind of helped to grow the channel as well. And yeah, but you know, like originally all of the contents that I created initially on the channel was more into like our, um, like our, for data science. Um, and I remember a lot of the subscribers were kind of asking for like wire, uh, can you create more contents into, uh, into Python?

  61. Speaker 2

    Um,

  62. Speaker 3

    So yeah, I vividly remember all of the videos that were R. People would say, create Python content. And then I eventually created some Python content and stuck to Python from then on. There were no complaints. And occasionally, some would be like, could you create more R content as well? Yeah.

  63. Speaker 4

    Yeah, there's always some. But I wondered if that would happen. I am curious, how do you find someone to collaborate with on YouTube? Because I've looked into that a little bit myself. How do you network with other YouTubers?

  64. Speaker 3

    Yeah. You know, like initially I was more like an introvert. So I really kind of just stayed in my lane, kind of, you know, create content by myself. And so Kenji was the first network who I collaborated with. So he reached out on LinkedIn. We kind of started a chat there and then kind of have like a virtual chat on Google Meet. And then we took it further from there. And then we kind of, you know, like created podcast videos.

  65. Speaker 2

    Oh, cool.

  66. Speaker 3

    Sometimes we draw illustrations on data science, and then he would put it into this video and give a shout out. And yeah, there are cross promotions there.

  67. Speaker 4

    Nice. That's really cool. I like hearing about how people succeed on YouTube, because that's really fun. Do you have any tips for someone who wants to start a channel or grow their channel at all?

  68. Speaker 3

    Yeah. So starting a channel, I think it's one of the most difficult thing to actually press the record button on the camera. And also a lot of the people, including me, would think that you would need the proper gear before you could actually start recording the video. But actually just a phone, just an iPhone or just a typical phone that you have, It's more capable. It could take 4K videos, and that is all you really need. But what I would recommend is to get a very good mic, either a lavalier mic or maybe invest $50 into a decent microphone. If audio is good, people are more inclined to watch the entirety of the video. But if the audio is not that up to par, they might click out of the video. Yeah, but, you know. Cool. Yeah, just kind of hit the record button and don't think much about it. Every first video will suck. I know my first video sucked. Yeah. Yeah, I remember one YouTuber, I think it was Roberto Blake, he mentioned that you should make 100 videos, you know, 100 crappy videos is what he mentioned. Yeah. that we don't have this high bar that we have to look up to when we want to create the video, which might hinder us from creating the video at the first place. So yeah, don't think much about it. Just record. And also, it doesn't mean that when you're a YouTuber, you have to know more than other people. It's just like sharing ideas, sharing information. And actually, I learned a lot from being a YouTuber. I even learned about Streamlit from one of the subscribers. They mentioned in the comments, have you heard of this web framework called Streamlit? Could you make a tutorial video about that? And yeah, subscribers would suggest all of these awesome tools in the comments section.

  69. Speaker 4

    Yeah, I've always liked that about commenters. I usually have a lot of people who comment on my blog posts, and I get some really good blog post ideas from that. So it's cool to hear about the same thing happening on YouTube.

  70. Speaker 3

    Right, certainly, yeah.

  71. Speaker 4

    All right. So what are your favorite non-technical hobbies, if you have any?

  72. Speaker 3

    Well, I occasionally would assemble, you know, like crafts, you know, like one of those robots, robots. It's called Gundam. So you would piece it together, you know, like piece by piece into a functional robot. But it doesn't move. So it's just for show only. I don't have it here in the U.S. I just, you know, relocated to the U.S. just recently. Thailand. Yeah. So everything is back home.

  73. Speaker 4

    Yep. Are these Gundam robots really big, or are they just really small scale models?

  74. Speaker 3

    Yeah, they are small scale models. So if you watch the anime, they're kind of like Transformers. So these robots are maybe 132 or 178 to scale. Okay. But they do have a real life-size robot in Japan in one of the shopping malls. I think it's over at Odaiba in Tokyo.

  75. Speaker 4

    Cool. I know Gundam's really big over there. I can't remember. I think I've watched the show that was out before they called it Gundam. I can't think what it's called now. Oh, well, anyway, I used to watch a lot of anime. Anyway, if so, what else? Is there any other hobbies besides building scale robots you want to mention?

  76. Speaker 3

    Well, travel. Nice. Traveling is good. Walking around the neighborhood.

  77. Speaker 4

    Do you have a favorite, like mountains versus beaches or lakes or anything like that?

  78. Speaker 3

    Nothing. No preference, but I think more into walking. You know, like... To spend the day without thinking too much about it, it's also a good time to relax and heal from the fast pace of life. Slow living, enjoy the peace and recharge the battery from there. Yeah, I get that.

  79. Speaker 4

    Yeah, I enjoy walking too. That's cool. All right, so I think we ended up getting to the end of my questions. So I just want to thank you so much for being on the show today.

  80. Speaker 3

    Yeah, it was a pleasure being on the show.

  81. Speaker 4

    Thank you. And I'm going to include links to your YouTube channel and Streamlet and some of the other things we talked about in the show notes. So everyone should definitely go and check out your content.

  82. Speaker 3

    Yeah, thank you so much. Yeah.

  83. Speaker 4

    Hit subscribe and don't miss the next episode.

  84. Speaker 1

    Mike Driscoll, The Python Show.