Overview & Use Cases - Jupyter
Learn more about Jupyter notebooks in our dedicated course: Using Jupyter Notebooks
00:00 Welcome to this final section that’s going to cover Jupyter Notebooks as an example for data science related editors that are—well, of the Notebook type, there’s a couple of them, and I would say that Jupyter’s probably the most common one, and it’s also free and open-source, so it’s a great choice.
00:18 I’m going to show you how Jupyter Notebooks work and what’s a good way of using them. Keep in mind that there’s also a separate course that we have on Jupyter Notebooks that goes a bit more in-depth than we do here. Okay, let’s get started with a quick overview and the use cases.
00:36 A Jupyter environment, the so-called Notebook, looks pretty much like this. We have cells in here that you can execute. You have up here a menu of different features that you can do, and you have up here a menu with the different menu items, things you can do.
00:53 I’m just going to go ahead and run these few code cells to show you how working with a Jupyter Notebook looks like. You can execute a cell by pressing Run here.
01:04 This is going to import some libraries that are very common in data science. Here, we’re creating some random set of data. And in this one, we’re going to plot it. There you go.
01:16 And you can see that I’m executing each cell separately, which means that I can write code in one cell, and then continue with the output, the variables that got generated in a different cell, but I can have the execution happen all in one cell and then a separate execution in the next cell. So in this case, I imported a couple of data science related libraries, then created this random set of numbers, and then created a plot.
01:43 And you can see how useful it is to get the output right here underneath a code block. This is where the Notebook idea comes from. You can basically read over this code very simply and see “What does the code do?” There’s also the option of integrating Markdown right in here.
02:00
I can say # My demo
and write just normal Markdown, normal text.
02:12
notebokks
? notebooks
, there you go. And you might see that this is a code block at the moment, but instead, I can turn it into a Markdown block, and then we already see that this recognizes Markdown correctly.
02:24 We can execute this cell and have just a normal, nicely-formatted HTML Markdown code sitting in here. And this allows you to create very, very nice and easily-readable documents that combine both code and explanations.
02:40 You can convert those to PDF, print them out, you can share them online, et cetera. And this is a very popular way for people that work in data science to create their work and also share it. You can see it’s interactive.
02:52 You can play around with the data. You can figure out things, quickly change it. And it’s just a very dynamic process that, at the same time, allows people to keep track of what’s been happening in here and retrace the steps that someone took to come to a certain conclusion.
03:09 So, this is why Notebooks are generally highly regarded and widely used inside of the data science and data analysis community, which Python has a big part in.
03:20 We’re going to dive a little bit deeper in there and walk through creating this little code sample. A little bit of debugging, and then I’ll tell you how you can learn more about using Jupyter Notebooks.
03:32
Okay, see you in the next section, where we will build our little for
loop inside of Jupyter Notebooks.
Martin Breuss RP Team on Feb. 19, 2020
Hi @angellondres500. It is possible that you are using an old version of ipython
that doesn’t yet support this specific magic function.
Check with:
import IPython
print(IPython.sys_info())
Your version should be above 1.0
. If it isn’t try updating ipython
with the package manager you used to install it (e.g. conda
or pip
).
If that doesn’t solve your problem, try some other suggestions e.g. in this StackOverflow thread. Remember that it often helps to search for your exact error message and try out some of the solutions people are suggesting online. Hope that helps!
Geir Arne Hjelle RP Team on Feb. 19, 2020
@angellondres500 It might be that you have a typo, it seems you’re missing a t
in your command: It should be %matplotlib
.
Martin Breuss RP Team on Feb. 19, 2020
Great eye for spotting that typo @Geir Arne Hjelle! And completely besides the point, I’d be interested to see someone hack together a new package called matpLOLlib
😜
gdwl on Feb. 27, 2020
Just a note to be careful with typos in package names. It has been known for malicious code to sneak in with names subtly changed from the expected ones. Twelve cases were found on PyPI back in 2018.
Martin Breuss RP Team on Feb. 28, 2020
Thanks for mentioning that @gdwl. Indeed, installing a mistyped package can be a security vulnerability. When these attacks are done intentionally it is called “typo-squatting”. So it helps to train that 🦅👁 like @Geir Arne Hjelle.
Become a Member to join the conversation.
angellondres500 on Feb. 19, 2020
I got this error sageError: Line magic function
%matplolib
not found.Could please tell me how to fix Thanks Angel