Start Jupyter Notebooks

Start Jupyter Notebooks

Anaconda installation

  • Because no spaces, so there is no electionC:\Program Files

Understanding Jupyter Notebooks

Use Jupyter Notebooks amazing features

Jupyter Notebooks where developers have built a number of predefined amazing features, make your life easier and make your work more interactive. You can run the following command to view the list of functions (Note:% symbols are usually required because completion that are usually open):

%lsmagic

You will see a list of a lot of options, you might even recognize some of them! % Clear,% autosave,% debug and% mkdir functions Surely you've seen before. Now, the magic command can be run in two ways:

  • Progressive way
  • Unit by unit way

As the name implies, progressive format command is a single line, but is by way of the command execution unit more than one line, but performs the entire code blocks in the entire unit.

In the progressive mode, all of the given command must begin with the characters%; in unit-wise manner, all commands must start %%. We take a look at the following example to better understand:

Progressive way:

%time a = range(10)

Unit by unit way:

%%timeit a = range (10)min(a)

I suggest that you run the code in person and see their differences!

Python-- not limited to the use of R in Jupyter Notebooks, Julia and JavaScript

The magic can be more than that. You can even use other languages ​​in your notebook, such as R, Julia, JavaScript and so on. I personally like the ggplot2 R package, so use it to perform exploratory data analysis with a very big advantage.

To enable R in Jupyter, you need IRKernel. It is that you can get on GitHub for a special kernel R's. It takes eight steps have been explained in detail, in addition to screenshot instructions, see:

https://discuss.analyticsvidhya.com/t/how-to-run-r-on-jupyter-ipython-notebooks/5512

Julia if you are a user, you can also use in Jupyter Notebooks in Julia! You can view this data as Julia users to learn science written a comprehensive article on which there is a chapter on how to use the environment in Jupyter Julia:

https://www.analyticsvidhya.com/blog/2017/10/comprehensive-tutorial-learn-data-science-julia-from-scratch/

If you prefer JavaScript, then I recommend using IJavascript kernel. The GitHub repository contains the steps to install the kernel on different operating systems:

https://github.com/n-riesco/ijavascript

Note that before using it, you must first install the Node.js and npm.

Jupyter Notebooks of interactive dashboards - why not?

Before you consider adding widgets, you need to import widgets package:

from ipywidgets import widgets
basic types of widget typical text input widget based on the widget and the button widget input. The following example is from Dominodatalab, give some appearance of interactive widgets: the

complete guide on widgets, see:

https://blog.dominodatalab.com/interactive-dashboards-in-jupyter/

Keyboard shortcuts - to save time and be more productive!

Shortcut is one of the biggest advantages of Jupyter Notebooks. When you want to run arbitrary code block, just press Ctrl + Enter on the line. Jupyter Notebooks offers many keyboard shortcuts that can help us save a lot of time.

Here is a shortcut to manually select some of us to get started for you will be a great help. I strongly suggest you try one by one while reading this article. Future you will not do without them!

Jupyter Notebooks offers two different keyboard input modes - command and editing. Command mode is the keyboard and notebook-level command to bind together and are represented by gray with a blue border units left margin. Edit mode allows you to enter text (or code) in the active unit, the unit shown in green border.

You can use the Esc and Enter to jump between command mode and editing mode, respectively. Now try it!

After entering the command mode (At this point you do not have active unit), you can try the following shortcut keys:

  • A inserts a new cell on the active unit, B unit inserts a new active cell below.
  • Press twice D, a unit can be deleted.
  • Retraction unit is deleted, press Z.
  • Y currently active cell will become a unit of code.
  • Hold down the Shift + or down arrow to select multiple units. In multi-select mode, hold down the Shift + M can merge your choice.
  • Press F will pop up "Find and Replace" menu.

When in edit mode (when the command mode by pressing Enter will enter edit mode), you will find the following shortcuts are useful:

  • Ctrl + Home unit reaches the starting position.
  • Ctrl + S to save your progress.
  • As previously mentioned, Ctrl + Enter run your entire cell block.
  • Alt + Enter will run you more than the unit block, will add a new unit below.
  • Ctrl + Shift + F to open the command panel.

To see a complete list of keyboard shortcuts available in command mode, press the "H" or go to "Help> Keyboard Shortcuts." You must always look at these shortcuts, because often add new ones.

Useful Jupyter Notebooks extension

Extension / add-ons is a very productive way to help you boost productivity on the Jupyter Notebooks. I think one of the best tools to install and use extensions is Nbextensions. Install it on your machine simply two steps (there are other installation methods, but I think the most convenient):

Step 1: Install it from PIP:
PIP install jupyter_contrib_nbextensions

Step 2: Install the associated JavaScript and CSS files:
jupyter contrib nbextension install -user

After completing this work, you will see a Nbextensions tab at the top of your home page Jupyter Notebook. One click, you can see a lot of extensions that can be used in your project.

To enable an extension, simply check on it. Now I give the four I think the most useful extensions:

  • Code prettify: it can re-adjust the format and content block beautification.
  • Printview: This extension adds a toolbar button to invoke jupyter nbconvert current notebook, and you can choose whether to display the converted file in a new browser tab.
  • Scratchpad: This will add a temporary storage unit, so that you may be able to run your notebook without having to modify the code. When you want to test your code but do not want to change your laptop in real time, it would be a very handy extension.
  • Table of Contents (2): This great expansion can collect all the titles in your notebook, and displays them in a floating window.

This is only a small amount of a few extensions. I strongly suggest you see a complete list of extensions and experiment their functions.

Save and share your notebook

This is one of the most important and most outstanding features Jupyter Notebooks. When I have to write a blog post, my code and comments will be in a Jupyter file, I need to first convert them into another format. Remember that these notebooks are json format, it will not be very helpful when performing share. I can not paste a different cell block in the e-mail and blog, right?

Into the "Files" menu, you'll see a "Download As" option:

This is one of the most important and most outstanding features Jupyter Notebooks. When I have to write a blog post, my code and comments will be in a Jupyter file, I need to first convert them into another format. Remember that these notebooks are json format, it will not be very helpful when performing share. I can not paste a different cell block in the e-mail and blog, right?

Into the "Files" menu, you'll see a "Download As" option:

You can use seven kinds of optional format for saving your notebook. The most commonly used is .ipynb files and .html files. Use .ipynb files for others to copy your code into their machines, using the .html file can be opened as a web page (will be very convenient when you need to save embedded pictures in notebooks).

You can also use nbconvert the manual option to convert your laptop into a format such as HTML or PDF.

You can also use jupyterhub, address:

https://github.com/jupyterhub/jupyterhub

It will make you notebook hosted on its server and shared by multiple users. Many of the top research projects are using this approach to collaboration.

JupyterLab - the evolution Jupyter Notebooks

JupyterLab was launched in February this year, is considered to be the further development of Jupyter Notebooks. It supports more flexible and powerful program operation, but the assembly has the same Jupyter Notebooks. JupyterLab environment and Jupyter Notebooks environment exactly the same, but with higher productivity experience.

JupyterLab let you arranged your laptop, terminal, text files and output results in a workspace window! You can just drag and drop the unit you need. You can also edit Markdown, CSV and JSON and other common file formats and real-time preview modify the impact caused.

If you want to try on your machine JupyterLab, you can view installation instructions:

http://jupyterlab.readthedocs.io/en/stable/getting_started/installation.html

JupyterLab long-term goal of the developers is to eventually replace Jupyter Notebooks. But now it will take some time.

Best Practices

Although working alone may be interesting, but most of the time you are a team. In this case, it is important to follow the guidelines and best practices, to ensure that your code and Jupyter Notebooks are appropriate comment, to be consistent with your team members. Here I list some best practices metrics, be sure to follow when you're working on Jupyter Notebooks:

  • One is the most important thing for any programmer - always make sure you add appropriate comments to your code!
  • Make sure your code has the desired document.
  • Consider a naming scheme and consistent. This can make it easier for others to follow.
  • No matter what your code needs to libraries, import them all at the beginning of your notebook. (Next to the comment and add that you load their purpose)
  • Make sure you have the proper spacing of the code. You do not keep circulation and function on the same line - or if you want to refer to them later, will make people crazy!
  • Sometimes you have a very large number of files of code. You will see if you can think of some code to hide unimportant, after re-quote. This makes your notebook looks clear and clean, which is very valuable.
  • View this notebook on matplotlib see how succinctly can be presented:

http://nbviewer.jupyter.org/github/jrjohansson/scientific-python-lectures/blob/master/Lecture-4-Matplotlib.ipynb

Another additional tips! When you want to create a presentation, you may first think of the tool is PowerPoint and Google Slides. In fact, your Jupyter Notebooks can also create slideshows! Remember I said Jupyter Notebooks are flexible it? I can not exaggerating.

To convert your laptop into a slide into the "View → Cell Toolbar," then click on "Slideshow." Now, the right of each code block shows a "Slide Type" drop-down options. You can see the following five options:

Epilogue

Note that this article is far from complete coverage of Jupyter Notebooks features. There are many things to you will be used in even more after use. Features are numerous, but the key is to practice makes perfect.

This library contains some interesting GitHub fascinating Jupyter Notebooks:

https://github.com/jupyter/jupyter/wiki/A-gallery-of-interesting-Jupyter-Notebooks

This guide is your starting point for a journey of scientific data, I am pleased to forward with you!

Guess you like

Origin www.cnblogs.com/gitwow/p/11468788.html