r/Python • • Jan 29 '16

Jupyter Notebook 4.1 release

http://blog.jupyter.org/2016/01/08/notebook-4-1-release/
41 Upvotes

15 comments sorted by

7

u/xilni Jan 29 '16

ELI12 Jupyter please.

I'm just some stupid Python newbie who's happy to use IntelliJ IDEA for his Python work.

11

u/[deleted] Jan 29 '16

I would just recommend to try it, it's really simple and definitely worth the time.

It is basically a notebook with a python interpreter. You can write notes in the notebook, but you can also write python code in the notebook and execute it. Executed python code will cause the notebook to display the result (if any).

It is perfect for trying/playing around, or to show people how you solved some problem. Not so much for writing entire programs.

6

u/[deleted] Jan 29 '16

Yeah, trying to write anything substantial gets convoluted really quick. I write the program in pycharm, and then import it into the jupyter for interactive visualization.

1

u/bouldering_prazman Jan 31 '16

I tend to do it the other way around. Experiment with different algorithms and visualise the results. Once I am happy with it, copy the code over to pycharm into neat little classes and commit.

1

u/[deleted] Feb 03 '16

I haven't tried Pycharm because I was introduced directly to pandas and Ipython notebook and never looked elsewhere. I use jupyter exclusively.

Am I being inefficient? I basically read files, do analysis and add columns or clean, then export results to a database.

I like jupyter because I can see the data and check the columns to make sure my logic worked or my joins worked etc.

1

u/[deleted] Feb 03 '16

No, for your use case it sounds like an interactive notebook works perfectly. But if you ever want to create something with lots of classes, each with tens of methods, you really should put each class in a separate file, and the best way to organize and debug all of that is a traditional IDE.

For me the magic of jupyter/pandas is I don't have to implement my own plotting methods and wrangle with matplotlib directly. I just store data as pandas dataframes, import my module into jupyter, and then do object.data.plot() to get beautiful inline plots.

1

u/[deleted] Feb 04 '16

I like the sound of that. I use basic matplotlib for checking but I always used pandas to prepare data for a tableau friendly format.

Honestly I have not touched a class or method.. I only have a few custom functions which I modified from stackoverflow.com. I bet there is so much more I could implement to save time and gain more insights. I'm using pandas like excel.

15

u/[deleted] Jan 29 '16

if you are doing webdev or games, it is completely useless.

If you are doing scientific programming, it is quite handy.

7

u/keturn Jan 29 '16

You can also work with Jupyter (IPython) notebooks in PyCharm: http://blog.jetbrains.com/pycharm/2014/12/feature-spotlight-ipython-notebook-inside-an-ide/

It was a little rough when they first released it. I should give it another shot now that they've had a while to refine it.

7

u/skrillexisokay Jan 30 '16

There are many uses of the Jupyter notebook. The three that come to mind are:

  1. Demonstrating code: Notebooks are a great way to mix explanation of code (through markdown cells) with the code itself. It makes it easy to walk the reader through the your own thinking. For example, you can define helper function and explain what they do, then show the ultimate result using those functions, and finally explain the significance of the results. This is especially useful for education or for scientific computing. In both cases, it's important that the reader fully understand the code and its purpose.

  2. Development: Many python programmers have a workflow that makes heavy use of the interactive prompt. For example, when writing a function, you might open up the prompt, load example arguments as global variables, and then try things until you get the result you want. The problems with this strategy are that it lacks organization and that you end up typing the same thing again and again. The notebook gives you essentially an interactive prompt, but also allows you to save blocks of code that you might want to execute again.

  3. Plotting: The main way I use notebooks... I often create a pandas DataFrame with non-notebook code and pickle it for future use. Then I open up the notebook and can inspect the DataFrame, alter it as I see fit, and plot it inline. That is, I can write a plotting line like `seaboarn.factorplot('weight', 'diabetes', hue='economic_class') and see the results right there, tweaking the plot as I desire. Later, I can then completely log out of my computer and easily return to my previous state by loading and running the notebook.

It's not a replacement for an IDE or a text editor. I view it as a glorified interactive prompt, and a communication tool.

5

u/spinwizard69 Jan 30 '16

As someone suggested try it out. It is a little different that regulate IDE programming. Some compare it to MatLab and similar apps I the way code and output is handled.

If you are new to programming, realize that this is a conceptually a different way to develop code. However it has great potential for a number of disciplines from research to education.

2

u/Deto Jan 30 '16

I always thought that Spyder was the closest thing to MATLAB

2

u/LoveOfProfit Jan 30 '16

That's been my experience as well. Very similar feel between Spyder and MATLAB

1

u/ClintonCanCount Jan 30 '16

I suppose it depends on how you are using MATLAB, but in general the Jupyter Notebook is more similar to the popular notebook interface to MATLAB.

I prefer Jupyter, though; MATLAB does some weird things.

2

u/ClintonCanCount Jan 30 '16

It is the old "IPython Notebook"

Basically, it is a system somewhere between a console and an IDE-

you write your code in a sequence of cells, and execute them- typically top to bottom, but you can change/run any cell in the program.

It is excellent for the kind of explorations, and simple computations, that I run in to as a mathematician.

It would likely not be as excellent for app development, but for quick-and-dirty writing of short algorithms and the like, it is in my opinion unparalleled.