Pysheets: The Spreadsheet Ui For Python
Speaker

Chris Laffra is a software engineer and open-source contributor focused on simple solutions. He created Pysheets, an innovative Python spreadsheet interface aimed at Notebook users. In the past, Chris helped create trading platforms at big banks. He optimized developer tools and cloud environments at tech companies such as Uber and Google. Chris is passionate about empowering engineers in software development. He authored the Communication for Engineers book.
0:00[Music]
0:14What I want to do um talk to you about today is a product called Spy Sheet. But um a little bit of history about myself.
0:22I've been in technology half my life and in finance the other half. So I mean like coding in finance. I'm a software engineer uh but in different organizations but I've always cared about communication between engineers and other people and engineers between engineers. Actually wrote a book about this as well. So that's the other half of my life is
0:43talking about communication and I bought a couple extra ones. So if you want a copy meet me afterwards and then find me and explain to me why you think communication is important and you get a free book.
0:57Um, so in my career, I've always seen uh business people and IT people having a problem communicating with each other.
1:03So IT people are typically, let's generalize here, um, nerds, uh, computer scientists. We like to solve problems.
1:11I'm one of them. Uh, events like this cost me energy. I don't want to talk to people. And business people, they want to tell the IT people what to do, but they can't explain in terms of technical things. So we're always fighting with that. Um, it has been like that since I started. I started with mainframe programming. Actually, my first coding
1:30was on cards with pens and that we sent to uh somewhere else in the Netherlands and it took a week for you getting your answer back and it said like syntax error on card 17. So the round trip there um well let's let's now talk about how how short the the round trip is now.
1:49But there are silos and we want to break them down. So what I will do is talk about bi sheets. You see a QR code here.
1:55So, uh, take a picture of it. Go to Py Sheets. Uh, follow the link and try it out. Um, go to the GitHub repo. It's an open source project and I'd like to get more more stars than 22. Uh, there's 22 right now. We need to get to a thousand.
2:10Come on, guys. Uh, so go to the QR code and please, please start it. So, I want to talk about the problem. Why pie sheets and what problem am I solving?
2:21And it comes down to actually looking at the underlying text stack that we have today which is Python um Jupyter notebooks and dashboards for basically explaining the data science findings that we find as as coders and and engineers and big data analysts and give to the business. Uh but Python programmers are from Mars and the business are from Venus. There's that
2:47book about relationships between men and women. It's the same four Rs. So I want to bring them in a closer orbit.
2:55So notebooks, what's wrong with notebooks? Jupyter notebooks, um, there are intrinsically linear. I call them one-dimensional. So they're linear. You you you start at the top, you write something and you go down. And this is fine for uh science papers that explain a certain theory and then go down the steps and each step you can validate and run the
3:16code. So notebook are extremely popular in that domain. There are like seven million notebooks on GitHub alone.
3:25So there's nothing wrong with that. But the way that most people think about things is graphs. So I think in graphs like my PhD topic was an object-oriented language and we had objects working as agents and they're sending messages to each other. So very quickly if you want to explain how things work, you start drawing circles and arrows and you draw
3:45a graph. And this is still today like this morning we had perfect presentation by Julia on lang chain and she focused on visualizing that graph so that we can actually see what is happening and including the cycles in the system. So for me everything is a graph. Um I said like I was coming from the Netherlands.
4:04Um the Netherlands is known for tulips and strobe waffles. I also brought stro. if you want to staff up on that. Um, but we're also known for graphs and uh, everybody who has heard of the Dystra shortest path algorithm uh, that was written by a Dutch professor Dystra. So, so we have a history with graphs in the
4:23Netherlands and I want to fix that. Uh, so what is wrong with Python and Excel?
4:28That's the other uh, observation that I had is last year Python and Excel came out from Microsoft. It's now in production. But if you want to use it, you have the the yeah, they charge you $24 per month extra on top of Microsoft 365.
4:43So that's one problem. But also, Python and Excel means that you can run Python inside the Excel spreadsheet in a cell instead of having traditional Python or Excel expressions. You can use Python code, but it should really be called Python outside of Excel because it runs on Azure in the cloud. It doesn't run locally. So the theme of this conference
5:04here is local first or local run everything local. So I wanted to fix all of this. So um Python in Excel I think that's for losers. Um what I want to do is Excel in Python. So I wrote it. I wanted to prove that it's possible to write a spreadsheet run it in the browser and run all the code in the
5:24browser as well. Store everything in the browser and see how far I can get.
5:29So first a quick demo and my machine should still be up and running. So this is when you go to py sheets.app if you follow the QR code that I had in one of the slides. You end up here. So this is an explanation of what the project is about. Uh it explains the problem we're solving. There's a link to
5:48the pitch deck. So this is for all the investors in the room here. Uh go there, click on it, get excited, call me, give me $3 million.
5:57Um the link sheet is there but also the slides for this presentation is there and there's a try button. So the try button will actually run it. So let's click that and this opens up PI sheets itself. So this is what's running right now. So this is not so impressive this UI. Um there's a toolbar and buttons but
6:17this is all run in Python. So Python code creates this UI when it runs in the browser. And if I create a new sheet, it actually renders a spreadsheet in the browser. So what happens here is we have a couple VMs starting up. So let me get my mouse, which is actually my pocket here. That's a little bit easier.
6:39So what I have here is uh two VMs running. So one is the micro Python VM.
6:45So, Python is uh compiled into web assembly and it runs inside uh the web assembly stack here inside the browser.
6:53But I have two VMs. So, one is MicroPython to do UI startup and you can see it's like 80 milliseconds. There are some words there. It's clipped off. So, the green line says running MicroPython.
7:04So, this is for the UI and it's about 80 milliseconds. So, we talked a lot about like small numbers, right? Try to run things fast. But to run pandas, you need a bigger Python VM. And that's the official CPython VM. So I have two VMs.
7:19One is the UI and the other one is in a worker and it can do all the work um like doing things. So what can you do here? Well, it's a spreadsheet. So you can enter words in here. But let me copy paste something from an existing spreadsheet. So this is Google Sheets.
7:35So I'll I selected an area and I would do copy and then go back to my untitled sheet here. And here I can do Ctrl +V and this will paste um from Google Sheets into Py Sheets.
7:49And now I have a little table here, country, import, export. And these are fake data of course. But what I can do next is uh select an empty cell. And you can see there's this extra button here.
8:00So what uh this is what I call um LLM buttons or magic buttons or that's why the star is there. So you can click on this and what it will do is it create a prompt senses to chatgpt or open AI and it generates the Python code to implement my prompt. So this is the code generation from that and what
8:23it did is it created a pandas dataf frame. So this whole effort is actually a dedication to best mckinley. uh he talked this morning at the as as the first speaker about the second speaker about um him designing pandas data frames like 16 years ago or so as a as a young programmer. So this is like uh
8:47pandas data frames are the standard for uh basically data science today. So what you get now is a pandas data frame. So I turn this text into a data frame. But you see there's another button that appeared C7 and I click on that and it says like visualize a data frame. Oh, this is actually creating a loop. Hey, that shouldn't be doing that.
9:08So, let's go. Let's start over. Um,
9:14believe me, I practice this a lot and you still make error. So, this is this is why you never do demos, but I'm I'm like sort of like a rebel and I still do demos. I don't listen to people give me advice.
9:27Uh so I create a data frame
9:32and then in a different cell I say visualize this. So this is the prompt again. This goes to open AI and it comes back with an answer. Um the screen real estate is always a challenge. But this code um I actually added this AI because I didn't know what metplot lip API was about. So I had to learn myself and I
9:52was starting like going to Stack Overflow and this is hey this is silly we have AIS these days. So all this code here is generated automatically and this is a bar graph right now. So let's uh make it a little bit smaller. So for this demo I can move it around. Let's make another one. So I use the same
10:09prompt that will give me another bar graph. But if I like pi pie charts so here it says make a figure. So I do a pie chart.
10:20So I'll just change the prompt and regenerate. It will generate new code. And now I have basically two visualizations for the same data.
10:29So as you can see there's uh there's a dependency graph like I talked about this earlier like um we think about things as graphs. So I thought like I also have to show you what the graph looks like. So when I hover over the graph of this chart, you will see it's a it's a figure and the figure depends on
10:45the data frame and the data frame comes out of this data. So if I now change this and say 50, this dependency graph gets executed and all the data updates.
10:54Uh so that's about it. Um it's interesting here you can even do things like XKCD which is very popular
11:05um way of visualizing your code. And now it's an XKCD pie chart. So you see how quickly that is without knowing too much of the APIs. You can do this data science and this is an exploration tool.
11:16We want to figure out like what does my data look like? Everything runs locally and that's the whole uh point of this.
11:22So what does it mean to run locally? I mentioned that I got two VMs. One a microython VM which is for embedded devices. Starts up in like in 100 milliseconds. So it builds the UI very quickly. The other one is a full-fledged Python VM that can run pandas and metapot lip and it runs in a worker and
11:38they talk to each other. They send messages but all locally. They can also talk to the spreadsheet. So if you want you can actually escape your sandbox and change everything that's in the UI and that is impossible in Excel. Uh I demoed this to Guido from Rossam the uh inventor of Python and he said like he he tried to lobby he
12:00works at Microsoft now and he tried to lobby for the Excel team to open up from the cell so you could actually contribute to like the menu bar for instance but they wouldn't do that. So um so if you want to do that use spy sheets.
12:14Um so running locally is important. Everything is in the browser. Um so storing is also important. Where do you store your data? There's a lot of emphasis today on different database solutions. And so what I did is uh I wanted to make it easy when I started with py sheets like uh 10 10 months ago.
12:32I thought like okay I'll just do app engine. I know how app engine works and I use firebase and then I was showing this to a customer a potential customer and they said yeah there's no way we can use Google app engine. It has to run locally on prem and it has to use our database. What which database? And they
12:48said bongo. Okay. So I'll spin off a source graph Kodi and I refactoed my code in an hour and it ran on and then they said well maybe my SQL okay go back to the AI and regenerate the code and this is like we went through the iterations in a day and then I heard about this conference and I thought like
13:09yeah I should really try to make it really just local. So the final version that you just saw the demo of, if you go to the um the URL and you try it out, you will store your sheets in index DB.
13:22So there's no external storage anymore. Everything is local. So I'm trying to be sort of like Yeah. Uh I'm not going to say the word, but retentive something retentive. Yeah. Yeah. I wanted to make it really really really local. So that's um uh what I tried. So the next step uh so we have run locally, store locally.
13:41So prompt locally. Uh so what I did is uh talked to this customer they say yeah we can't use open open AI of course right I work at a bank this is like we can't send our data there and work our code whatever there's compliance reasons why you cannot do that there's also cost involved of course. So then I thought
14:00like wait I'll just install and I do it locally. Um I was very hopeful. I bought a new PC which is a co-pilot plus PC which can run AIS locally on it. So I thought like this is going to work, right? Uh not really. So um so there's a
14:17local definition. This is a definition of the word local. Of course you need a beefy machine. I should have bought uh maybe a MacBook M3 Max and then I could have run locally. But for any definition of local, if you have a local machine and a local data network this morning, we talked about like the exponential curve of of how these machines
14:37grow over time. I'm I'm I'm I'm confident that you can run a locally trained model and run it locally and save yourself a lot of mo uh money when you do experiments like this. So we got three or three three things we have run locally, store locally and prompt locally and this will give you lots and lots of benefits on yeah doing your data
15:02science in this way. Um, I tried to install Gemini Nano, but I'm still waiting for it to be activated in my browser. And uh, if anybody here has experience with that, please let me know.
15:17And finally, I showed this uh, example. I like I said, I showed it to a couple people that inspired me to actually do a startup on this. Um, I showed it also to Carol Willing, who is the co-inventor of Jupyter Notebooks, and she said like, "This is what Jupyter Notebooks should have looked like when we started it."
15:33So, so that was a great compliment I uh got from her and it's also my marketing position. So, this is not a replacement for Excel. This is not replacement for Google Sheets, but it's more a replacement for uh Jupyter notebooks that allow you to think about your problem not in a linear one-dimensional structure, but more in a two-dimensional
15:53even three-dimensional uh way of thinking of the dependency graph. uh this is a very popular way of thinking about this problem at large investment banks like Goldman Sachs and uh Bank of America and JP Morgan specifically there's a history of building uh huge trading platforms based on dependency graphs and getting people off the spreadsheets and have real programming
16:17approach to this problem. What I wanted to do is bring these worlds together. So it's it's more a a cultural solution than a technical solution that I was going for. But of course I spent a lot of hacking time on making it perform well. There's a lot of like engineering that doesn't show in this demo. Uh this
16:36talk to me afterwards and I can share all my nightmares. So with that, thank you uh for your attention and come meet me afterwards. I'd like to talk more about Py Sheets and also about communication for engineers. If you're an engineer struggling with your career, you want to get promoted, you want to make more money, I will tell you how.
16:55So, see you there. [Music]


