Data Science with Jupyter Notebooks
Interactive data science with Jupyter notebook
The way I run Python code live on the screen is by using a Python package called Jupiter. Jupyter is built into the IPython project and allows Interactive Python to run in your browser. But it is more than that. From special command "magic" and bash commands to plugins, Jupiter greatly enhances the Python coding experience.
If you are already using Jupiter, I hope I can improve your workflow and show you some new tricks. If you are not yet using Jupyter, then log in.
Installation and startup
The easiest way to install Jupiter is to install the pipe using Jupiter, although if you use a package Python distribution like Anacondo, you may have already installed it. Be sure to activate your Python environment first. We dive.
When you turn on Local Jupyter, you'll connect to a locally running webserver through your browser, usually on the 8888 port. Start your notebook by running Jupiter Notebook in your work directory. Normally Jupiter will open automatically once it starts, but if not, show your browser to local host: 8888 point.
If you don't already have a notebook that you want to open, you can create one by clicking on a new one and selecting Python 2 or ing, depending on the version of Python you're running in the environment. Jupiter is quite flexible and can actually handle many languages and file types, although we will only stick with Python for now.
Code running on Jupiter notebook
Once you have a new notebook, you can write some Python code in the blank cell and just use ctrl + enter. We can run all our specific Python code here, just like you would write in Python script. The difference is that we can run it and see the results now!
Notice what happens when we run a cell with a ctrl + enter. The bracket to the left of the cell shows the asterisk when the cell is running or queuing to move the key, and then it shows a number after the end, which cells were starting at '1' in the given session respectively.
The result of the last line of the code cell will be printed as the output of that cell, but only if the value is not stored in the variable. For example, if I import TensorFlow and then connect it with a string, the output is shown below, even if I don't use the print command.
Of course, I can also use print (). It’s all very useful for tinkering and seeing how some behave.
Shift-tab
Another great feature of the Jupiter notebook is the ability to display the document of the function you called by pressing the Shift-tab. This allows you to call a function with the correct arguments.
This feature also works with your own local customization functions, so if you write good documents, you will be rewarded!
Results
When you have a lot of output, you can reduce the amount of space you take by clicking on the left panel of the output, which turns it into a scroll window. If you double-click, the output will be completely destroyed.
More cells!
One cell is useful, but we really want more cells. To add a cell, click the 'plus' icon in the toolbar. There are also some cell execution commands that can create new cells.
If you press Shift + Enter, it will play the current cell and highlight another cell. If there is no new cell, then a new cell is created. On the other hand, if you want to create a new cell immediately after a given cell, you can use Alt-enter to execute the cell and then insert a new cell behind it.
Comments
Post a Comment
If you have any doubts. Please let me know.