shiny & Python

A relatively basic exploratory data analysis shiny app written in Python
shiny
Python
Published

August 20, 2022

Overview

This app is an initial exploration into shiny for Python which was revealed at rstudio::conf(2022) earlier this summer.๐Ÿ๐Ÿ๐Ÿ

Aim

The aim of the exploration was to try out the API and see whether I can recreate common patterns/functionalities I use in my other apps.

The app is simple: Use the sample data (or upload your own) to run a basic linear regression analysis and display the resulting plot.

Functionalities

Here are the functionalities covered in the app:

Deployment

I currently have my app running on shinylive.io which seems to be a very promising serverless solution. You can also build your app as a static site (locally) and serve it via github pages or netlify.๐Ÿคฏ๐Ÿคฏ๐Ÿคฏ

๐Ÿ‘‰View the app + code in editor mode: make changes and execute it all within the browser See Here๐Ÿ‘ˆ

๐Ÿ‘‰ View the app served on github pages See Here๐Ÿ‘ˆ

The one downside is that not all libraries are supported, which is understandable. I originally used the xport library to read SAS .xpt files instead of .csv files in development. Winston Changโ€™s talk provides more detail about this and the technology in general.

Future

If and when this is included (or I figure out the rsconnect deployment, which is also an option by the way), the following code can be replaced easily to read .xpt

import xport

def p():
        if input.file1() is None:
            return "Please upload a csv file"
        f: list[FileInfo] = input.file1()
        with open(f[0]["datapath"], 'rb') as z:
          df = xport.to_dataframe(z)

Thatโ€™s about it. I plan to do a blog post summarizing the experience further and my thoughts around the news of Rstudioโ€™s โ€œmoveโ€ into the Python space later.

๐ŸปโœŒ