Writing an interactive dataframe editor with fasthtml

Ever wanted to edit a pandas dataframe object in python in some interactive way felt too limited by streamlit but also did not want to pick up html / css / javascript just for that?

Then one solution could be fasthtml, or python-fasthtml as it is called on PyPI. With that package you can write your client facing web code as well as your server side code from the comfort of python. And, if you manage to wrap your head around it, you can also use htmx. Not quite sure I’m fully there yet myself :-P.

So using fasthtml, I’ve built a small app to edit a dataframe and uploaded it over on GitHub for you: https://github.com/eschmidt42/fasthtml-data-editor

There are two python files, main_simple.py and main_hx.py. The first creates the website in a more vanilla way, reloading the entire page when updating the dataframe. The latter uses htmx and replaces only the dataframe bits.

I’d recommend to compare them side by side. You’ll notice how the differences are quite minor.

References I found useful tinkering with this were

Happy coding!