Jupyter notebooks have transformed the way many developers and data scientists do their jobs.
They offer a platform to not just explore, but to explain data and computation.
But how are they really being used? Adam Rule is here to describe his research and PhD dissertation,
which analyzed over 1 million Jupyter notebooks found out in the wild.
This is Talk Python to Me, episode 171, recorded July 6, 2018.
Welcome to Talk Python to Me, a weekly podcast on Python, the language, the libraries, the ecosystem, and the personalities.
This is your host, Michael Kennedy. Follow me on Twitter, where I'm @mkennedy.
Keep up with the show and listen to past episodes at talkpython.fm.
And follow the show on Twitter via at Talk Python.
This episode is brought to you by Linode and Studio 3T.
Please check out what they're offering during their segments. It really helps support the show.
Adam, welcome to Talk Python.
Yeah, great to be with you. Thanks for inviting me on the show.
Yeah, it's great to have you here. I'm really glad our mutual friend, Philip Guo, introduced us and suggested this show.
Yeah, no, you've had a lot of great people on the show.
I mean, Philip included, who I think has been a repeat on the show, which is great.
But other folks in kind of my area of data analysis or computational notebooks, Min and Matthias from Project Jupyter and DJ Patel, one of the kind of godfathers in data analysis.
So it's an honor to be on here with you today.
It's great to have you on. It was great to have those people as well.
So we're going to talk about Jupyter Notebooks in a super meta way.
Like, I've had Matthias on to talk about notebooks in, like, as a technology.
But we're going to talk about more, like, how people work with notebooks and how it affects researchers and data science and stuff.
Before we get to that, let's start with your story.
How did you get into programming and what led you down this Python path?
Oh, gosh.
I mean, my original track was I was an industrial engineer as an undergrad.
And I thought, oh, I like people a little bit, but I also like science and math.
And so industrial engineering is this mix of both of those where you're trying to optimize, like, production flows.
But then you spend some time on the shop floor talking to people about, like, how's this working for you?
How can we make this process easier for you?
From there, it's a somewhat circuitous path, but eventually took me to understanding, oh, not just designing manufacturing processes,
but we can design devices and products and software for people.
And, gosh, designing software for people is really difficult because you can't just look at, you know, measure how long is their arm and lay out the workspace that way.
But you have to get into their head a little bit and try and figure out, okay, mental capacity and how do people think through things?
What's a workflow look like for that, not just how I work a work piece through a factory?
So with that, I got into programming largely by studying how people use software and needing to do some of my own programming to build software.
Add-ons to really look deeply at how is it that people are using these technologies and how can we make them easier to use or just do more powerful things
and augmenting what we can learn about how people work in their capacity.
Yeah.
Oh, that's really cool.
It's super interesting how this sort of engineering path led you over here.
I think industrial engineering plus software would be a really cool space to work because there's just so many gadgets and things you could design with just a little bit of smarts and a little bit of programming that would be amazing.
Like, that's a skill I don't have.
Yeah.
I know that kind of fusion of the two worlds would be really fascinating.
I think it's a little ironic.
One of the things I really like about programming is you actually get to build stuff, which you get to build stuff that is, like, conceptual, right?
But it runs.
And I'm speaking, like, coming from a math perspective, right?
Where it's like, prove this cool theorem about topological spaces.
I guess I'll go look at another theorem, right?
Like, you don't actually have an outcome, right?
Here, even though it's sort of virtual, you still get to build things.
But this would take it to another level.
Awesome.
So you started writing software to kind of understand and study how people interact with it, which is sort of started you down this meta path, right?
Yeah.
I know.
I think today as we get further on the talk, it'll be very meta as we talk about studying how people use tools like Jupyter Notebook by, in turn, using Jupyter Notebook to analyze a data set about people using it.
It kind of becomes turtles all the way down.
Yeah.
I was just thinking it's turtles all the way down.
Absolutely.
Yeah.
So what led you into, like, Notebooks and Python, right?
Like, you could have, say, used C++ to understand how people use software.
It would take you longer, but you could have done it.
Yeah.
No.
And this may be going back a little bit too far, but I was really fascinated by HealthKit and how physicians use medical records to track and document their work.
It's this really data-driven domain.
But it's really hard to get into.
You can't really say, oh, let me just hack on your enterprise software system in the hospital.
I just want to tweak it in this way and see if that makes it easier to care for patients.
One, the software systems are super complex and regulated, and you have kind of patient risk there as well.
And so I turned and looked at another very data-driven domain, data analysis.
And honestly, it's just by kind of hearsay of so many people saying, hey, have you checked out these notebooks?
They're fantastic.
I've been using them for months or years now for doing analysis.
They're pretty amazing.
You should really look at this.
And so where I was at UC San Diego, a bunch of people were using these tools for very basic biology, neuroscience research.
So that got me into looking in, okay, how are people using these tools to track and talk about very complex data-driven work?
Yeah, that's awesome.
So maybe that's a good place to segue into kind of what you've been doing recently.
So you said you are at UC San Diego, a very nice school down in San Diego.
And you just finished your PhD as a human-computer interaction researcher, which is a sub-portion of, say, cognitive science.
And I was really surprised how much computer programming and software is involved in cognitive science more broadly.
Yeah, I know.
Cognitive science is an interesting field that's kind of a fusion of psychology and computer science.
And you go back to some of the early days looking at folks like Herb Simon and others at Carnegie Mellon and around the world.
And they were playing in both fields of developing and testing a lot of software, trying to figure out, can we model how the brain works?
And then there's kind of the reverse transition of people will look at the brain and use that to try and figure out how can we build more efficient algorithms or computer systems with neuromorphic computing.
But yeah, I just finished my PhD a month ago, actually.
So still fresh off of that.
Are you just super relaxed now?
I am.
No, I was going to say, I'm almost in this academic sabbatical period where we still have funding and I'm still continuing to do some of the research that we'll talk about today.
But due to my wife's job, I moved to a different city, now up in Portland, staying on the West Coast, but very different in terms of sunshine hours from San Diego.
Less sunshine, more green.
More green, which is great.
Yeah.
When I moved to San Diego from Seattle and when I was in Seattle, really loved the lush green.
And so San Diego has many benefits.
The surfing, the burritos, the sunshine, but it lacks in green.
So it's good to be back.
Nice.
So you still are finishing up this research a little bit that we're going to be talking about.
And then it's time to hit the real world.
Are you thinking academics?
Are you thinking industry?
Where are you headed?
Yeah, I'm thinking industry at this point.
Just to try my hand at something slightly different and see what that world is like.
Gotten a good dose of academia for the last five years of PhD and two years of master's before that.
That's a healthy dose.
What the working world is like.
Awesome.
All right.
So maybe we should start by talking a little bit broadly about what human-computer interaction is.
Yeah.
And I think Philip has covered some of this as well because he researches really similar topics.
But it's really studying the design and use of computer technology.
So how do people use current technologies?
And how do certain aspects of the design make it easier to use for particular tasks?
So as I was saying with cognitive science, it's really a mix.
Human-computer interaction, the subfield, is really a mix of computer science and social science.
So some days I'm building software.
Other days I'm testing it with people.
Other days I'm just sitting and observing how people use it or don't use it during their tasks.
So it's this flopping between programming and observing and social science, more anthropological skills.
That's a lot of fun and goes back to my industrial engineering days of the math and science and the satisfaction of building things.
And then the flip side, trying to understand people as well.
Oh, yeah.
It's a really interesting mix.
Are folks in that area starting to think about how artificial intelligence is changing this?
Like things like the Amazon Assistant or the Google Assistant and stuff like that?
There's a bunch of research in that area.
I think some of the folks who are farthest out ahead on that are those in the human-robot interaction field.
Because they've had to think for a while about how are people going to interact with robots and reason about how is this computer device reasoning about things and making decisions?
And should I trust that?
Or does it not have access to all the information I do?
And all these things we do very naturally with other humans of like, oh, they don't see that car coming because they're looking this other way.
I should let them know.
It's harder to do that with computer systems where you're less sure about what are the inputs, what's the processing, what are the outputs going on.
That's really interesting.
It's going to really become more and more so over time, isn't it?
Yeah.
And then all this work on like machine learning interpretability.
How are you going to be able to interpret a decision that came out?
I know there's work going on in that.
And even here in Portland, the next HCI researcher meetup in the area is focused on machine learning and how do we design for this and help people understand what's going on.
So I think both in academia and industry, it's a big deal right now.
Oh, yeah.
That's awesome.
It sounds like people who want research projects, I suspect that's a good place to focus.
Good place to look.
Yeah, for sure.
You decided to focus a little more meta.
You wanted to focus on these computational notebooks, which Jupyter is one of.
But maybe give us like let's set the landscape, right?
So in the Python space, we hear Jupyter, Jupyter, Jupyter.
Oh, Jupyter lab is slightly better.
Jupyter lab.
And then that's about it, right?
But there's actually a slightly broader view of these things in the history as well, right?
So there's actually a really interesting article in the Atlantic that was coming out and saying, oh, the academic paper is dead and computational notebooks are going to replace them.
And a lot of that talks about Jupyter notebooks, but it goes into some of the history of notebook platforms back to really Mathematica is the one that's often credited with being one of the first environments where you could have this literate programming back and forth, typing and running small scripts in a specific language to analyze data or ask questions.
So that was back in the 80s.
And there were academic systems like Maple that were in schools in the 90s and 2000s.
But it's been in the last couple.
I remember using Maple.
That thing was magic.
Yeah, no, I remember using it as well.
And I haven't really seen it much outside of the educational context.
I don't know if that's just their niche or what.
But so it's been around for a while, but it's often been locked away in proprietary software that you had to pay a big license fee for.
And so it's really in the last decade or so and really the last five years or so that platforms like Jupyter notebook or RStudio have been providing these open source and in some cases like Jupyter free environments for using a notebook like interface to play with data.
Yeah, what's your take on when I was working on my master's degree and my PhD and stuff, which I didn't get my PhD, but I did get my master's degree.
But anyway, when I was working on that, you know, I was using MATLAB and stuff and we were doing things like wavelet decomposition, which I'm pretty sure the license was 2000.
This is like an add on to MATLAB was like 2000 additional dollars per person that was using it like that's completely insane.
Yeah.
And then here comes Jupyter and whatnot and going, oh, actually ours is free.
Why don't you try that?
Well, that's a big effect, right?
Yeah.
And thinking about, you know, there's a huge push in science for open science and not just sharing your results, sharing the data, but then sharing also your code and how you you arrived at that.
And the fascinating thing is so many researchers are making, you know, you talked about the wavelet decomposition.
They're making their own packages or libraries, especially in the Python ecosystem and sharing them openly for others to use and download.
And that's really seemed to move up the stack to not just be the packages, but the language, you know, Python should be open and free.
And the environments, the development environments like Jupyter should be open and free.
Do you see this like Zen of open source from the scientists interacting with the software, like flowing into science directly in the sense that people are sort of changing their way?
Do you see other stuff by virtue of having these open source experiences?
I think so.
And a couple of points on that.
Some of the folks that I talked to and we get to some of the research that I've done talked about this really strong obligation they felt to make things open source, to make them reproducible.
And it was almost a religious zeal of like, this is just how things should be done.
And I hadn't seen that really before in academia, in other contexts.
I think one of the other interesting things I saw is so many labs where, you know, half the lab might be wet lab biology folks who are running experiments and, you know, creating slices and staining them and using microscopes.
And the other half really just looks like a startup or a software development group who are doing code reviews on a weekly basis.
They have a GitHub repository, maybe.
GitHub repositories talking about versioning, remote, you know, workers calling in from across the world and seem very much like just a software company.
But they're in a research lab doing fundamental biology research.
Yeah, I really do see this computer science skill starting to permeate a lot more stuff, not just so we have more programmers, but so that, like what you described, these biologists can take some of these software ideas and just really amplify what they're doing in the lab.
Yeah, absolutely.
This portion of Talk Python to me is brought to you by Linode.
Are you looking for bulletproof hosting that's fast, simple, and incredibly affordable?
Look past that bookstore and check out Linode at talkpython.fm/Linode.
That's L-I-N-O-D-E.
Plans start at just $5 a month for a dedicated server with a gig of RAM.
They have 10 data centers across the globe.
So no matter where you are, there's a data center near you.
Whether you want to run your Python web app, host a private Git server, or file server, you'll get native SSDs on all the machines, a newly upgraded 200 gigabit network, 24-7 friendly support, even on holidays, and a seven-day money-back guarantee.
Do you need a little help with your infrastructure?
They even offer professional services to help you get started with architecture, migrations, and more.
Get a dedicated server for free for the next four months.
Just visit talkpython.fm/Linode.
So I did sort of cut you off a little bit when you were talking about the history.
So we've had Mathematica and Maple and MATLAB, and then we've got Jupyter in our studio.
But then there's a bunch of hosted ones as well that maybe some people have heard of, but there's actually a ton of variety out there for even just getting these and running them online.
Yeah.
So I mean, even just sticking with Jupyter, one of the great things about Jupyter is they have the notebook itself, kind of this front end.
But I think some of the more lasting impact from Jupyter might be just the standards that they set about how are we going to send messages back and forth to a kernel?
What's the notebook format and the very specific JSON structure?
So in a way, they're almost like a standard setter, like World Wide Web Consortium, HTML, or other things.
This is just how scientific computing or data analysis should be documented and shared.
And so a number of other groups have come and built on top of Jupyter in those standards.
So like Google Collaboratory is like a Google Docs version of Jupyter Notebooks, Microsoft's Azure Notebooks on there, you know, Azure Cloud, and then even Sage Notebooks.
Sage was this project in specific language, kind of like Mathematica, for doing data analysis and mathematics.
And they've now switched over.
Is that the, that's the Sage from William Stein up in Seattle, right?
Yep, that's exactly right.
So now they have a whole notebook infrastructure and each of these have, have made add-ons and different history features or profiling tools that are slightly different from Jupyter Notebook or Jupyter Lab.
But they're all essentially built on top of Jupyter.
Yeah.
And there's some really interesting cloud computing tie-ins.
Like I don't know Azure and Sage well enough, but I know on Google Collaboratory, like you hit a hotkey to run a cell and you hit a slightly different hotkey to run the cell on a GPU.
It's like crazy, right?
It's just.
Yeah.
And I think that comes into business models of how you're going to monetize these things.
Jupyter has this interesting model of being open source and funded by academic time and grants, whereas others are saying, well, we'll provide this software for free.
But if you want white glove support or to run it on our cluster, then that'll cost you at that point.
So it's free for smaller uses in educational context, but we'll provide the compute infrastructure.
That's pretty interesting.
There's also a JavaScript one, right?
Yeah.
So this kind of notion of computational notebooks is now spreading into the web world where Observable HQ.
So Mike Bostock, the mind behind the D3 data visualization library, now is a company that's making a completely on the web computational notebook.
So writing JavaScript code to analyze data.
And then Mozilla actually is starting up a project called Iodide that's looking at this.
And what's fascinating about these is you can write code not only to analyze the data, but to directly manipulate the notebook itself.
And so you get some really fascinating views on data or dashboards or something that you wrote in a cell just changes the complete layout or operation of the notebook itself.
So it mixes kind of the programming for data analysis and then programming to change the tool that you're using to do the data analysis.
How interesting.
Yeah.
Because you can reprogram the notebook with the notebook.
Yep.
So it makes it easy to do things that have been difficult to do in, say, Jupyter Notebook to create widgets where if I want a slider that can then change some parameter and a visualization I have, I can just call whatever that div is because I'm programming in JavaScript and select it and tell it to update on this callback.
Yeah, I definitely see that having an advantage in that integration as well as that runs on the client browser.
So the hosting cloud side of it is like, you could probably do that on a $5 server.
You know what I mean?
Like you could host an incredible amount of computation because you're just serving up the files more or less, right?
Yeah.
So all of these really interesting models all around this idea of a notebook infrastructure where you incrementally write a few lines of code to analyze data and then get the outputs printed right in line.
One weakness, I guess I would call it, that I see with a JavaScript computational environment is JavaScript has poor numerical support.
Yeah.
It's like integers, for example, are super hard because integers.
And I'm not sure, I mean, even beyond that, just the infrastructure, you know, there's all sorts of great infrastructure, especially in Python and R for data manipulation and cleaning and analysis.
And those libraries just, I don't think are quite there for JavaScript.
Right.
Where's the pandas for JavaScript?
Does it exist?
It may, I don't know, actually.
Or the tidyverse.
Again, it may exist, but it certainly doesn't have, I think, as many folks working on or using it as you do in the Python or the R worlds.
Yeah, it's interesting that it exists.
Okay, so that sort of sets the stage of this world.
And your PhD goal was to go and study that world and actually understand how people use these computational notebooks and if they're really fulfilling their promise of becoming like a computational narrative or what are people doing this, right?
So maybe tell us more about your research.
There's this Atlantic article that came out and made this declaration of the science.
I want to encourage people to check out that article.
We're going to put it in the show notes.
It is, I think I've talked about this before on Python Bytes, my other podcast.
But anyway, it's really provocative, right?
Like there's a scientific paper that's literally on fire, like an animated fire on the homepage.
It's quite something.
And it's a big change.
Yeah, no, it makes some bold claims.
It roasts Stephen Wolfram quite a bit.
And then it goes into kind of the history of Mathematica and then also Python and these different views of like a closed type ecosystem like Mathematica where you make your own language or an open one like the Python community where anybody can write a library and contribute.
But yeah, so one of the things in this article, and really this just reflects some of the zeitgeist right now, is this notion that, well, in the future, we're no longer going to be sending around scientific results just in a dead PDF because that doesn't give you all the information you need to reproduce science.
You know, the analyses we're doing today are so complex that you can't just read a three sentence description of it and know what to do.
Yeah, I think I've heard somewhere some kind of quote saying your academic paper that you write about your computational results is like advertising for that computational result, but it's not actually the research.
Like the software is the research in a sense, right?
So why are these two separate things?
Yeah, I know, I think you had some talks with folks behind Journal for Open Store Software.
Yeah, I think that's where that came from is that one.
Yeah.
And just like so much of the work and research now is software development, whether it's for building a package to do a certain type of analysis or that particular analysis itself.
You know, this article and others are saying really what we need is a new medium where you can share all of the code used to run the analysis because so much of analysis is now happening via programming, not in Excel.
Not with SPSS or other packages for stats.
But if you just share the code, that's really not understandable either.
You know, we all hope to comment it well.
And so what you need is this mixed narrative.
And that's what notebooks give.
You can write a line of markdown text that explains what the notebook's doing.
And then you can just build up your argument and show how you collected, analyzed, and did this data.
And so a lot of folks are saying, hey, scientific paper is dead.
Notebooks are the new medium.
And look, millions of people are using them.
And we really wondered, is that the case?
You know, is the scientific paper dead?
How are people using these notebooks?
Because despite being around for decades and having millions of users, we know very little about how people actually use them in their day-to-day work.
So we sought out to kind of understand better how are people actually using these things?
Is there much rich computational narrative?
You know, if we read these things and understand the analysis.
Or are people really just using them because they're a nice iterative development environment?
And so that's kind of what got started down this path.
Right. Is it a place where you load some data and you just sort of iteratively explore it and interact with it?
Or are you actually trying to put something like a paper together, right?
Like the next version of that.
Those are really compelling reasons to use notebooks.
You know, having this really tight REPL that will let you iterate and just explore some data.
Or having it be this really well curated explanation that you can share with others.
Yeah, this idea of a REPL is really handy and nice.
But sometimes it's just super hard to go back to what you want.
You know, you're like, well, it's 20 things back.
And this, you know, a bunch of them are like 10 lines long.
So you got to go.
It's just, you know, it's not very, very nice to interact with it, say, off of the terminal in some situations.
But this, this is perfect, right?
You can go back and read it.
You know, just jump to where you want by touching it.
It's great.
So how did you, how did you get your data?
You, how did you find these notebooks to study?
Just like go ask a couple of people, you know, or what, what do you do?
The first part of the research that we did was trying to just get a big sample of notebooks.
So he said, one way that we can tackle this problem is just try and get a bunch of notebooks and look at them and see what the content is.
So we ended up actually scraping all of the Jupyter notebooks that were on GitHub at the time of the study, which was about a year ago.
How many is that?
So that was a little over a million, about one and a quarter million notebooks they had on there, which that was a fun process of working around rate limiting to get that to work.
Yeah.
So tell us how do you do that?
I mean, was that GitHub API?
Was that web scraping?
What was the flow there?
Yeah, and it was a mix of both.
So GitHub is a great and well-documented API.
But in order to do what we wanted to do, we had to abuse it a little bit.
They don't really want you looking for just one specific file type.
So you can't really just search and say, show me all the files of this type and download all of them.
You need to give it some other parameter set.
So we actually had to go and say, OK, give me all the Jupyter notebooks between, you know, zero and 100 kilobytes.
OK, between 100 and 200 and kind of iterate them through that way, both to get a list of all of the notebooks.
And because they limit, we're only going to send you a thousand results.
So even if you can look and see that there's a million of these, we'll only send you the first thousand.
So we had to restrict our query down to get it in packets that were small enough.
I see.
You had to come up with an arbitrary filter criteria that would get it below a thousand.
OK.
Yeah.
And then from there, it's just a lot of learning how to be a good citizen with GitHub servers and respect when they say, OK, you're making too many queries and slow down.
It took a couple of weeks, but we eventually got the full data set that way.
And then afterwards, we had to do some web scraping to get the files themselves.
So we essentially first got a list of what are all the notebooks and where are they?
And then used some web scraping to get the files themselves.
Yeah, that's pretty interesting.
And it only took a couple of weeks.
I mean, on one hand, that's a long time.
On the other, you've gone out and gathered all of these millions of notebooks from all these sources.
And that's pretty amazing, actually.
No, I think it's fascinating that, I mean, GitHub provides the tools for us to be able to do something like this.
And really only asks us in return that we make the data in any publications open afterwards, that you can use their API to really study how people all over the world are using a tool set.
So it's a great way to get a massive and diverse sample size.
Yeah, I think GitHub is kind of a special place, right?
I mean, there's lots of source control and versioning and issue tracking places in the world, but GitHub stands alone.
And it's sort of reach and just people using it and so on.
Yeah.
So what was, I guess, how do you go about studying it?
Like, you're studying Jupyter Notebooks.
Did you actually use Jupyter Notebooks to study your Jupyter Notebooks?
This is exactly it.
Yeah, so this is where it gets super meta.
So we download this whole data set.
And for those who don't know, Jupyter Notebooks themselves are really just a JSON file.
They have a different ending, I, PI, and B, but under the hood, it's just a JSON file.
So we essentially have a million JSON files to look at.
And so we just spun up our own Jupyter Notebooks, imported that data set, started making some data frames using the Python ecosystem.
And so analyzed it that way.
So in the end, it's come full circle because the Notebooks that I used for my analysis of Notebooks on GitHub are now hosted on GitHub.
Completely available.
So you will be a data set in the follow-up replication setting.
Is that what you're saying?
Yeah.
How interesting.
This portion of Talk Python is brought to you by Studio 3T, the IDE for MongoDB.
No SQL databases offer maximum flexibility.
But what if you could combine the benefits of MongoDB with the benefits of SQL?
With Studio 3T, you can.
With their innovative SQL query feature, you can write SQL joins and expressions to query MongoDB.
And the best part is you get to see how your SQL queries translate to MongoDB's native query syntax with the click of a button.
You can create MongoDB queries, aggregation statements, and SQL queries.
And 3T's novel query code will automatically generate code for you in a variety of languages like Python, JavaScript, and even C#.
Studio 3T also offers the richest coding experience with its full-featured IntelliShell.
It's the built-in MongoDB shell interface with smart auto-completion of collection names, shell methods, document key names, operators, and field names.
By using in-place editing within a collection, it's even easier to edit your documents.
Try Studio 3T and see why it's used by Fortune 500 companies like Nike, Tesla, Formula One, Comcast, and many more,
saving enterprise users countless hours of development time.
Visit talkpython.fm/studio to get a free one-month trial.
That's talkpython.fm/studio.
What are some of the findings or things you got by studying these?
We talked about this tension between an iterative REPL and then an explanatory narrative or computational narrative.
What did you find?
One of the big headlines from this bit of research was that very few of the notebooks had what you might consider the baseline requirement for a rich narrative,
which is just any explanatory text.
So over a quarter of the notebooks had no markdown text at all.
So they were just code or code blocks.
And then even of those that had text, they were pretty short.
So like the median was about 150 words.
So just a really short blurb.
Well, maybe those blurbs are almost like comments.
They just are in text cells instead of in code with a hash.
Yeah.
And they'd often be like, okay, import data, model data, really descriptive of the steps.
And I think for us that, you know, hints that more, you know, not that this is a bad use to the notebook,
but more they're being used as an interactive programming environment with some light, loose notes rather than this view of,
oh, there's this really rich description, like a scientific paper of what people did.
I think there are a host of reasons for that.
But that was one of the major findings for us from this.
Yeah.
So how much of this is just people happen to be using and storing their notebooks on GitHub versus they intend other people to consume those?
Yeah.
You know, it's hard to say for sure, but we think a lot of it is just we're going to throw it up as a repository for myself.
And I'm not really expecting others to use it.
We did an analysis where we actually looked at the descriptions of the GitHub repos where these notebooks lived.
So like how are people describing these projects and looked for keywords.
And when we remove things like notebook or GitHub from that keyword search, the top words are things like machine learning, Kaggle, Udacity, Nano degree.
And so that really showed us that a lot of these seem to be people learning how to do data analysis, learning machine learning in particular,
and doing online education assignments and then hosting their results up online, whether that's as a form of submission
or for a resume or portfolio building exercise.
But a lot of these seem to be educational.
Interesting.
I can see a lot of people who are students taking courses at a university or something, and their professor says,
all right, what we're going to do is going to create a repo for your course,
and everybody's going to put their assignment and just share it with me or make it public or something.
Our search excluded forked repos and forked notebooks.
So at least one form of distribution like that should have been excluded.
But yeah, I still think a lot of this is course assignments like that.
Did you do any refining where you say, well, let's look at repositories that have over a thousand stars or a lot of followers,
or just the ones that are not clearly sort of private?
We tried to look for ones that seem to get reused a lot.
And in fact, the motivation for us was, well, let's see if we can find best practices in notebooks, right?
Like if we can find ones that are in repositories that were starred a lot or forked a lot,
maybe that means that they were really useful and we can kind of glean some best practices on notebook design from this.
Right.
Maybe even a lot of PRs, they're getting like polished.
Exactly.
And one of the things we found when we tried to do that was many of these notebooks that were in highly starred or forked repositories were just tutorials for various software packages.
So as an example, it could have been, you know, something like here's pandas up on GitHub.
And then here's the notebook as documentation showing how to use pandas.
But the reason why this repository is so starred and forked is that people really like using pandas,
not because the notebooks themselves were all that insightful.
Yeah, that's interesting.
I guess it is a really nice way to have code mixed with description on GitHub because GitHub renders and executes those now.
Yeah, and that's one of the things is we're initially doing this research that people said why they're using Jupyter notebook and why they're putting it on GitHub is,
hey, a manager that I have, you know, they don't really want to install the software and set up an environment,
but I can just send them a link and they can see the notebook statically.
And that's a really nice way to share results.
Yeah, that's great.
Even managers can run web browsers.
Uh-huh.
Yeah.
I think one of the other interesting things that we looked at was in a testament to the Python ecosystems,
we said, okay, what are the packages that people are importing?
And just finding that the vast majority, around 90% or so of these notebooks,
are importing external packages.
And things like pandas, numpy, matplotlib, we're importing two-thirds or more of them.
So just the data science infrastructure that's being provided is a really core component.
It's not just having the notebook like Jupyter.
It's having the Python ecosystem to be able to do it.
It's the foundation.
Yeah, that's really awesome.
What about things like R and JavaScript and stuff?
Were you able to figure out, well, how much is Python?
How much is other stuff?
The notebooks themselves have a tag for what the language is in there.
And the vast majority of those, like 96%, were written in Python.
Whereas things like R and Julia, which is why Jupyter is named Jupyter, the combination of Julia, Python, and R, each accounted for about a percent.
And then there was a long tail of other languages that were supported.
But by and large, it was Python.
And kind of surprising for us.
96%?
That's actually higher than I would have even guessed, to be honest.
No.
And again, I don't know if it's because so many of these are educational.
And that's just a good language to teach in or what the reason may be.
But it still is strongly reflecting its IPython roots of being kind of a Python-first environment.
For sure.
It sounds like it.
So were you able to find a subset of what you might call academic papers or like these narrative type things and analyze those?
That leads into the second line of work we did on this is, okay, pull down all of these notebooks.
We've looked at them.
Very few of them have this rich description and seem to be more just using notebooks as a nice iterative environment.
But what if we're just looking at, you know, the wrong subset of notebooks?
Many of these seem to be for education.
It may be that people are just hosting these for themselves.
Yeah.
You probably don't want to look at a notebook that a student has like known programming for 10 days as a, how should we do things?
Exactly.
That's exactly it.
So like, okay, like, let's be a little humble with the limitations of the data set and our assumptions of it.
So we ended up saying, well, what if we look at what some consider like the creme de la creme of doing and presenting analysis?
What if we look at notebooks that are supplementing academic publications?
So this is back to that Atlantic article saying, you know what, in the future, scientific papers should just be in notebooks.
And there's a number of folks who have jumped on that bandwagon and said, you know, I may publish something in science or nature or one of the big journals, but I'm going to link to here's the notebook that I use for that analysis.
So that people can retrace it, recreate it, fork it, and continue the analysis themselves.
And as mentioned earlier, there are some in the academic community who have a real strong kind of evangelistic fervor around the need to share the results in this way.
So we ended up looking for those specifically.
Interesting.
And what did you find there?
Any differences?
Probably, right?
Yeah.
So we ended up finding, again, many of these are on GitHub.
So we pulled about 150 of them.
And we used a slightly different method where rather than just doing a big data analysis, we hand code it.
And we wanted to see kind of with finer grain detail.
I looked at it and I put it in categories, not like typing programming, right?
Exactly.
So putting the categories, kind of iterating those over time, and then making sure you have other people who can validate.
But yes, that's a valid category, not just something that you came up with.
Nice.
Okay.
So you coded these by hand and probably got slightly different results, I guess.
Okay.
So these notebooks have a little more text in them.
But surprisingly, they're not using that text really to describe the analysis in any rich way.
So of the notebooks that had any text in them, which was still not all of them, the majority would use that text just to describe the steps of the analysis.
Importing data, fitting model.
Back to the comments as text rather than comments as code comments.
Yeah.
Okay.
And then only about a third of them have what we might consider a rich description.
So any description of why they did the analysis in a particular way.
So, oh, I fit a linear model because these assumptions are met, or we tried this other model and it didn't work.
Or interpreting results.
So, you know, if you look at this plot, you'll notice this outlier here.
Most would just leave the end figure like it spoke for itself, often without axes labeled.
And just say, here's how we got the result.
And not really describe what they thought it meant or how they got there.
So that for us was surprising.
Again, thinking, well, academics will want their work to be easily understood and replicable, that so many of these still kind of fell short of Fernando Perez, Brian Granger's, and others' vision of this rich computational narrative.
How interesting.
Yeah.
So what did you do?
You go ask them, like, why didn't you write?
Why didn't you write more?
So in a way we did.
Not with the folks who had posted notebooks there, but we ended up finding people around campus at UC San Diego who are using notebooks.
Again, some of these labs where they have big biology analyses or genomics work and where using notebooks is kind of a way of life.
So we went and talked to some of those people.
So we ended up finding 15 of them and just walk them through, show us a notebook you've been working on, which was great.
We got to see kind of in progress work rather than just here's my finished product that I'm post on GitHub.
Yeah, that's cool.
And so were they also more using it as like repl type explorative stuff or what was the story there?
It was exactly that.
Again, people were using it for this iterative environment.
Some would talk about it.
It's my coding playground where I get to test out ideas, but it's a very personal thing.
You know, it's reflecting my style of programming.
And, you know, I'm not going to take time to clean it up for others because maybe they don't want to see it.
I was going to say, it seems like a really great thing for people to create these notebooks.
And then if you're meeting with your research group to pull it up and everybody look at it and kind of walk through it.
I wonder how much that played into it.
Like, here, look what I've been doing this week.
And here, let me show you the results and how I got it and so on.
Yeah, we have the same intuition as well.
And it seems like that's not the case.
And in fact, one of the folks that we talked to said, you know what?
I've tried this in lab meetings and people just think I didn't take time to prepare.
They think I'm just showing up by the skin of my teeth.
It's winging it.
Winging it.
And unless I have a slide deck put together that these aren't solid results or that I didn't take time to think about what you might want to see.
So it's this really interesting case where there's kind of this entrenched practice of you must present from slide decks or else it means this or that about your work that got in the way of using notebooks as a presentation medium.
Huh.
Interesting.
I wonder if it's a chicken and egg thing.
Like, if they were really beautifully formatted and descriptive, maybe that's a really great presentation.
But if they're sloppy, like, in and of themselves, maybe the presentation feels sloppy.
Or just the social expectation in practice.
Like, what if labs just expected that rather than taking time to create a slide deck, that you would take the time to document your code in the notebook?
That seems like that's more reusable and valuable over time.
Right?
Because, I mean, I've not refactored or reused slides that much.
Uh-huh.
Okay.
Wow.
What do you think needs to be done for notebooks to reach their potential, right?
To become this thing that would actually sort of validate the burning paper on the Atlantic?
I first want to say, like, I and the research who work with me think notebooks are fantastic.
I wouldn't want anyone coming away from the podcast saying, oh, you know, notebooks are done.
They're not the right way to do analysis.
I think they're the best thing that we've got going.
And there are vast improvement over prior ways of doing data analysis, which was often having, you know, script one in a file, script two in another file, script 2.5.
Version control is usually just naming copies of the files.
Exactly.
Yeah.
It's a much better way for version control and tracking steps of the analysis.
And, you know, through our research has demonstrated it's a fantastic way to iteratively do the process of analyzing data, especially with Python.
And so many people are using it for that.
For us, the real question is now, how do we make this wonderful programming environment also a wonderful presentation environment?
One where it's easy to share results with others and to support kind of collaboration in that way.
And I don't know a silver bullet to get it done.
I think there's things that we can do to tweak the design and how people use the notebooks.
But there also have to be some social changes.
You know, things like labs expecting the presentations will be from notebooks or journals expecting submissions in notebook format rather than PDF.
So I think it'll be a mix.
Interesting.
How much do you think like software carpentry type of stuff is involved here?
Like bringing a little bit of the CS side of things to the researchers?
Yeah.
No, I think that's really vital.
And I think the model that software carpentry has of doing the workshops and dedicated time to training these best practices.
One of the really standout insights from our last line of work, the interviewing researchers, was that one researcher mentioned that when she had started as a biology student in biology or chemistry labs, she was trained in a very specific way of tracking her results.
You know, this is how you write your name and the date and the reagents that you're going to use for this experiment and the steps.
And if she didn't do it in a particular disciplined way, she'd get docked points by her teaching assistant or professor because this was just the practice of how you document and share a biology or chemistry lab.
And she said, you know, we don't really have that for notebooks.
I came into the lab.
I was shown a notebook and told, have fun.
You type here.
Exactly.
But I've had to figure out like, oh, I can create my own packages and I can import external files.
And, oh, I can move all of the import statements to the very top of the notebook and, you know, have to kind of figure out best practices on their own.
So I think there's a lot of best practices, both from software development and engineering and from data analysis that have grown up in the last few years that can be brought to bear through things like data carpentry or software carpentry workshops that aren't there yet.
There's been a lot of progress there, but it also seems like, you know, there's always more progress to be made.
And I guess just from an academic perspective, every year you start over in a sense, right?
Like every year there's a new grad student who's fresh and they've never done this and they're at the lab and you've got to bring them under the fold, right?
So there's also this sort of mentoring aspect.
It'd be really interesting to look at how would our results be different if we'd done this out in enterprise, right?
Like a lot of what we looked at ended up being academic domain, whether it's all of these students working on notebooks that we found on GitHub or looking at folks who are in an academic lab environment.
And that's largely a factor of who we have access to and who's willing to share their notebooks publicly.
The rest of them, they're in these buildings right around campus.
We'll just go talk to them.
Uh-huh.
But looking at, you know, I think there's similar issues of turnover within organizations or handing off a project from somebody who's a senior analyst to a more junior, less experienced analyst.
And onboarding and disciplined practice.
Folks like Hillary Parker over at Stitch Fix had talked a lot about opinionated data analysis and having a disciplined way of tracking or sharing or reviewing data analyses and needing to develop that in enterprise.
That's pretty cool.
I wonder how accessible that information is because I know some of these companies are somewhat open about what they do.
But, again, this data analysis, this is partly what drives their company and they're not going to just give it away.
It's not like I can go to Goldman Sachs and go, hey, why don't you just publish your notebooks for your analysis?
Because that would be so interesting.
Yeah.
Like, yeah, we're not doing that.
Yeah.
I think the domain where I've seen outside of academia, the most open sharing of analyses is journalism.
So folks like FiveThirty or BuzzFeed or others who have published a number of notebooks online and even on GitHub.
So many of them are in our data set.
FiveThirty has got an amazing set of data on GitHub.
So FiveThirty has spilled out with letters slash data, I think is it.
Really interesting use of notebooks.
And, again, for them, it's kind of the incentives that we want to be open and show that we're a reputable organization and have others validate the claims that we make in our articles.
Whereas, you say, for companies, it's kind of the keys to the kingdom of this is how we generate value is our data and our building on top of it.
Yeah.
And I guess with journalism, once you publish it, you stake your claim to it.
Right.
But in business, like your sales model one year could be everyone's sales model next year.
Right.
That's not the same.
Yeah.
No one gives you much credit.
Yeah.
Yeah, for sure.
So what do you think about the future?
Like, we talked a little bit about this, but maybe packaging these things up, it's still maybe a little bit difficult to say, here's my notebook and go run it with everything that you need.
Should we look at containers?
What do you see going forward?
Notebook environments like Jupyter Notebook are going to increasingly become the core infrastructure for data analysis, both in industry and academia and journalism.
They've just proven so valuable as an iterative programming environment and for presenting results, though it still takes a lot of time to clean it up.
But yeah, I think for the future, there's a lot of work that will have to be done in a lot of different domains before notebooks get more widely used.
And as you referenced, some of it is in packaging the environment.
So theoretically, you can use notebooks to rerun somebody else's analysis.
But what if you don't have the same access to their data, either because of human subjects restrictions or it's just a lot of data or stored away on a server or your version of the libraries are slightly different?
So I think there's a lot of work on how do we containerize and package up not only the programming environment and the language at this point in time, but also the data.
That's interesting.
I think that gets into questions about, yeah, differential privacy and incentivizing data curation.
Right now, that's not really recognized often in academia, at least, as a contribution to the field.
Yeah, it seems like the cloud computing stuff that we touched on at the beginning helps somewhat with that, right?
Like the Azure notebooks, the Google notebooks, and Sage notebooks, and so on.
Like, you can share one of those.
But at the same time, I guess eventually maybe those things upgrade the packages that you have access to.
And that could theoretically change your results.
Like, oh, we fixed a bug in this analysis thing, which now doesn't look the same.
Who knows?
In discussions from some folks from library sciences, they'll say, you know, for as much flack as things like the PDF document give as a way of presenting results, PDFs and paper have proved to be a really stable way to share insights and knowledge.
Yeah, the versioning isn't nearly as touchy.
Like, we haven't had an issue of, you know, pulling a book off the shelf and it not working anymore, except if maybe the spine broke or something like we did with trying to run code that's even five or ten years old.
Yeah.
It's just a much more stable environment for storing knowledge.
So I think figuring out ways to do that will be really vital for things like notebooks becoming more integral to sharing results over time.
I agree.
I think containers have a lot of promise there because they can freeze the whole environment.
But even them, you know, they're based on some other operating system.
They've got to run on a certain version of Linux.
It's not perfect.
Yeah, it's not perfect.
Yeah.
And then as you referenced earlier, I think there's in the future a lot to be done in the realm of like software carpentry, data carpentry, scaling education.
As much as we can do to tweak these interfaces to make it easier to develop in or to write really clear narratives in, I still think a lot is going to rely on either apprenticeship models or mentoring or training in ways of doing and documenting data analysis.
So figuring out the right way to do that is a super tricky problem.
Yeah, it sure is.
I wonder if we're going to have some more specialization.
So in the early days, it's like, well, the people who want to do computer programming, they got electrical engineering degrees for whatever reason.
And then we have the CS degree in computer science.
Like, I don't know.
I don't feel like I've done any science really in computer for a really long time.
But it's, you know, that's what it's called.
Even though you're not actually staging hypotheses and doing things, you're just building.
It's more like engineering, right?
So we then got software engineering degrees that are slightly different applied ways of doing what computer science was doing.
Maybe we will get like computational scientist degree specializations or something coming along.
It's like half computer science, but half sort of these other data sides of things you're talking about.
I think many of the data science institutes that are popping up either online or at universities are trying to figure out like, what of this is specialized and unique to working with data?
What is it just rehashing things that we've already learned from software engineering and versioning?
What do we even have to specialize further in that biology's use of programming for data analysis will look fundamentally different from astronomy?
You know, the practices will be as different as AstroPy and another library are.
I can see a world where we end up there.
As computation becomes more and more the foundation of all these different degrees, that each degree is like, no, no, we're going to have a biological computationist degree.
It's not going to be over in the CS world.
It's going to be here and we're going to run it and it's going to have some CS, but it's also going to have lots of biology and other aspects.
Yeah.
And that's one aspect of future work we haven't gotten to, but I think would be fascinating is looking at how people use notebooks differently in different environments.
Both like how is enterprise different than academia?
How are beginning computer science students different from later ones?
Or, you know, how does astronomy differ from chemistry and how they use these environments?
So I think that's a fascinating area to look at next.
It definitely is.
All right.
Well, I think that probably is a good place to leave things.
Okay.
A pretty optimistic future.
We're getting a little low on time.
So maybe, maybe we'll ask you the two questions at the end of the show.
First of all, if you're going to edit some Python code, what editor do you use?
I'm really a Jupyter fanboy.
So used it whenever I need to analyze data, used it for this study.
And again, really like the environment.
The exception of that will be when I'm doing more software application development.
So I've actually, if I'm doing web development and have Python on the server side and JavaScript on the front end, then I'll often use Atom for that.
Just because I'm switching back and forth between languages.
Yeah.
If you have a bunch of different files and they're kind of all working together, especially cross language like CSS, JavaScript, HTML, et cetera.
All right.
It's something, Jupyter is not amazing for that, but it is really great for exploring.
Awesome.
All right.
How about a notable PyPI package?
I think Philip may have mentioned this too, but especially in the data analysis world, Anaconda, I have yet to find a better way just to get people up and running on doing data analysis and quickly package together pandas, numpy, matplotlib, seborn.
Especially on Windows.
Especially on Windows where some of those tools are hard to pip install because like some weird compiler thing is missing.
Yeah, that's cool.
Pick a specific one and probably be the visualization libraries.
Matplotlib or seborn are really where I spend my time.
Awesome.
Yeah, I'll throw one out for you.
I don't normally do this, but this one is like so relevant.
I just came across it.
Have you heard of Pixie Debugger?
P-I-X-I-E Debugger?
No.
So Pixie Debugger is a visual interactive debugger for Jupyter Notebooks.
That is fantastic.
You just include it and it gives you like below your cell, you put a little decorator type magic command onto a cell and then you can just step through, step forward, inspect the variables visually as you're going through that cell.
It's pretty awesome.
That is awesome.
Yeah, so many folks will split cells to try and figure out, okay, where does this thing fail?
So that's perfect.
Yeah, it's really, really great.
All right.
So people are interested.
They want to do more with this.
Maybe look at your research.
Is the data available?
What do they do?
I have a personal website, adamrule.com, that they can go to that kind of links out to everything.
And that will have copies of the papers documenting my research as well as links to the data repositories.
How big is the data?
Is it a lot?
It's about 600 gigabytes.
600 gigabytes.
Wow.
Thankfully, our university had a very fast internet speed to be able to down all of that.
Oh my goodness.
Yeah, yeah.
No kidding.
Where do you host it?
That's actually a non-trivial amount of money if you actually had to put it on S3 or something.
That's 50 bucks per download.
Props to UC San Diego again on that.
Their library has graciously agreed to host that.
So many other sites that we looked at had limits at like 100 gigabytes or something for data sets.
So they're hosting that.
And again, I have a link off of my website.
But we both have the full data set.
And then we have a starter data set.
It's about one to two gigabytes with a subset of those, but with all the different data types.
And example notebooks that people can use to begin playing with it.
Oh, that's really cool.
So they can start to play with it.
And if they're really committed, they can download 600 gigs.
Exactly.
Oh, that's pretty awesome.
Well, Adam, this is really interesting research.
And thanks for sharing your view into the whole notebook space.
Yeah.
Thanks again for chatting today.
It's been a pleasure.
You bet.
Bye.
This has been another episode of Talk Python to Me.
Our guest has been Adam Rule.
And this episode has been brought to you by Linode and Studio 3T.
Linode is bulletproof hosting for whatever you're building with Python.
Get four months free at talkpython.fm/linode.
That's L-I-N-O-D-E.
With Studio 3T, you can write SQL queries and translate them automatically to Python.
Try their database ID today at talkpython.fm/studio.
Want to level up your Python?
If you're just getting started, try my Python jumpstart by building 10 apps or our brand new
100 days of code in Python.
And if you're interested in more than one course, be sure to check out the Everything Bundle.
It's like a subscription that never expires.
Be sure to subscribe to the show.
Open your favorite podcatcher and search for Python.
We should be right at the top.
You can also find the iTunes feed at /itunes, Google Play feed at /play, and
direct RSS feed at /rss on talkpython.fm.
This is your host, Michael Kennedy.
Thanks so much for listening.
I really appreciate it.
Now get out there and write some Python code.
I'll see you next time.