1 00:00:00,400 --> 00:00:02,776 Now before I can do anything with charts and graphs, 2 00:00:02,776 --> 00:00:04,725 I need to get a couple of things installed. 3 00:00:04,725 --> 00:00:07,512 Luckily, we can do this even inside of our notebook. 4 00:00:07,512 --> 00:00:10,904 So I'm gonna add a new cell and 5 00:00:10,904 --> 00:00:16,620 I'm gonna type !pip3 install numpy and bokeh. 6 00:00:16,620 --> 00:00:19,868 Now if you have Python 3 installed to where you can just do pip, 7 00:00:19,868 --> 00:00:22,154 then you want to go ahead and do that as well. 8 00:00:22,154 --> 00:00:24,949 I'm gonna go ahead and execute that cell, and 9 00:00:24,949 --> 00:00:27,610 l can see up here that this is marked as busy. 10 00:00:27,610 --> 00:00:30,560 And l can see output showing up in here in this little star here. 11 00:00:30,560 --> 00:00:33,500 All of these things tell me that it's busy, and 12 00:00:33,500 --> 00:00:35,525 what's cool is if you hover over this thing, 13 00:00:35,525 --> 00:00:38,820 it'll tell you whether or not the kernel is idle or whether the kernel is busy. 14 00:00:38,820 --> 00:00:42,350 If the kernel was still busy, it would say that it was busy. 15 00:00:42,350 --> 00:00:46,530 So right now it's installing NumPy and Bokeh, or it was. 16 00:00:46,530 --> 00:00:50,330 NumPy is a package for working with numerical data, for data science. 17 00:00:50,330 --> 00:00:52,990 And Bokeh is one for generating interactive charts. 18 00:00:52,990 --> 00:00:57,450 Now, once this all wraps up, we can add our next block of code, or 19 00:00:57,450 --> 00:00:58,330 I could change this one. 20 00:00:58,330 --> 00:01:02,570 I'm gonna add a new one though, just to keep that bit of history in there. 21 00:01:02,570 --> 00:01:06,310 So I've got a block of code, you can check the teacher's notes for it. 22 00:01:06,310 --> 00:01:08,903 I'm gonna copy and paste it from my notes, though. 23 00:01:11,047 --> 00:01:16,320 So copy that, and then I'm going to come over here and 24 00:01:16,320 --> 00:01:19,640 paste that in, all right. 25 00:01:19,640 --> 00:01:22,420 So it's not super important what all's going on here, but 26 00:01:22,420 --> 00:01:27,990 this is using NumPy and some widgets to generate a sine wave. 27 00:01:27,990 --> 00:01:32,090 So I'm gonna go ahead and I'm gonna execute this with control and enter. 28 00:01:32,090 --> 00:01:38,630 And I don't get any interesting feedback, I just get this function main update. 29 00:01:38,630 --> 00:01:41,470 Now the reason that I get that is because I haven't enabled JavaScript 30 00:01:41,470 --> 00:01:43,170 inside of our notebook. 31 00:01:43,170 --> 00:01:47,000 You have to tell Jupyter notebooks that you're okay with it executing JavaScript 32 00:01:47,000 --> 00:01:48,500 inside the notebook. 33 00:01:48,500 --> 00:01:52,210 Now I can't turn this feature on from inside the notebook itself. 34 00:01:52,210 --> 00:01:57,940 So I'm gonna hop over to my terminal, I'm going to stop the notebook server. 35 00:01:59,090 --> 00:02:04,390 And then I'm going to run the code that I need to do so that I can execute this. 36 00:02:04,390 --> 00:02:07,510 So I stopped the server by pressing Control and C. 37 00:02:07,510 --> 00:02:11,230 On some systems you may have to do Control and D or Control and Z. 38 00:02:11,230 --> 00:02:14,750 Just play with it, you'll find which one works for your system. 39 00:02:14,750 --> 00:02:16,370 So now I need to enable the extension, 40 00:02:16,370 --> 00:02:19,440 the extension that I want to enable is the widgets extension. 41 00:02:19,440 --> 00:02:20,900 And we want it to be enable for Python. 42 00:02:20,900 --> 00:02:23,380 So we're gonna type the following command into the terminal. 43 00:02:23,380 --> 00:02:26,817 So here's the command, 44 00:02:26,817 --> 00:02:32,382 it is jupyter nbextension enable ==py 45 00:02:32,382 --> 00:02:38,120 ==sys-prefix widgetsnbextension. 46 00:02:40,640 --> 00:02:46,840 So nbextension enable --py --sys-prefix widgetsnbextension. 47 00:02:46,840 --> 00:02:49,070 This is in the teacher's notes, as well, if you just wanna copy and 48 00:02:49,070 --> 00:02:49,950 paste it out of there. 49 00:02:51,240 --> 00:02:53,960 You'll see that it's validated and it's okay. 50 00:02:53,960 --> 00:02:57,070 And then we're going to run Jupyter notebook again. 51 00:02:57,070 --> 00:03:00,845 And when we do, it will again open up, yeah go ahead and leave. 52 00:03:00,845 --> 00:03:04,890 >> It'll open up our thing and we will open up our notebook. 53 00:03:06,050 --> 00:03:11,440 And then, it looks like I'm gonna need to paste that code back in. 54 00:03:11,440 --> 00:03:14,290 And then I will run it one more time, control Enter. 55 00:03:15,510 --> 00:03:16,742 And down below now, 56 00:03:16,742 --> 00:03:21,318 you will see that we have a wonderful little thing here where we have waves. 57 00:03:21,318 --> 00:03:26,103 And if we were to change the values, it will change the wave right away. 58 00:03:28,163 --> 00:03:33,910 And we can change which wave type it is whether it's a sine or cos or a tan. 59 00:03:33,910 --> 00:03:36,030 And we can just kinda play around with this stuff. 60 00:03:36,030 --> 00:03:38,390 And then what's cool is we have over here tools for panning and 61 00:03:38,390 --> 00:03:40,350 zooming an stuff like that as well. 62 00:03:40,350 --> 00:03:43,260 So it's pretty cool, we have a bunch of widgets and we have a wave, and 63 00:03:43,260 --> 00:03:45,030 if we change the values we get a different wave. 64 00:03:45,030 --> 00:03:48,830 And it's all right here in the notebook, we don't have to use any extra programs or 65 00:03:48,830 --> 00:03:50,440 anything like that to see what's going on. 66 00:03:50,440 --> 00:03:54,580 It's really neat, you can do a lot more with extensions that what I've shown you. 67 00:03:54,580 --> 00:03:56,370 There are others available online and 68 00:03:56,370 --> 00:03:59,870 with them you can do things like use Python's turtle module to draw graphics. 69 00:03:59,870 --> 00:04:03,800 Explore other data visualization libraries and even use other languages. 70 00:04:03,800 --> 00:04:06,299 We'll explore the other languages a tiny bit in the next video. 71 00:04:06,299 --> 00:04:10,015 But know that there's a lot more out there for you to explore and discover. 72 00:04:10,015 --> 00:04:11,665 If you'd like to share your notebooks with friends and 73 00:04:11,665 --> 00:04:13,895 coworkers, check the teacher's notes for ways to do that. 74 00:04:13,895 --> 00:04:16,125 It can be as easy as putting the notebook on GitHub or 75 00:04:16,125 --> 00:04:19,055 Azure, using Project Jupyter's official notebook viewer. 76 00:04:19,055 --> 00:04:22,245 Or you can export the notebook to HTML and host it on your own server or 77 00:04:22,245 --> 00:04:24,495 another service that'll host static websites. 78 00:04:24,495 --> 00:04:27,100 Again, check the teacher's notes for more information. 79 00:04:27,100 --> 00:04:30,330 All right, let's see how they use Jupyter notebooks with more than just Python. 80 00:04:30,330 --> 00:04:32,070 I'm gonna have to take some notes here myself.