Three-dot continuation in Python Notebook

I’ve been working through some online tutorials that are HTML versions of Notebooks and some of them show this sort of thing:

In [9]: df2 = pd.DataFrame({'A': 1.,
   ...:                     'B': pd.Timestamp('20130102'),
   ...:                     'C': pd.Series(1, index=list(range(4)), dtype='float32'),
   ...:                     'D': np.array([3] * 4, dtype='int32'),
   ...:                     'E': pd.Categorical(["test", "train", "test", "train"]),
   ...:                     'F': 'foo'})
   ...: 

I can’t find any references to
…:
online, although I did find a single reference to

as the “secondary prompt” for an interactive Python shell session. I am guessing that
…:
was originally a part of iPython / Jupyter Notebooks and is no longer required for line continuation? But, apparently, it’s OK to include and is ignored by the interpreter?

Is there any documentation for this? Is it deprecated?

Ellipsis was a numpy innovation, I think, for helping work with slices across multiple dimensions, that allows you to say something like “and everything in all the other dimensions”.

Related docs: https://docs.scipy.org/doc/numpy-1.13.0/reference/arrays.indexing.html
Discussion: https://stackoverflow.com/a/773472/454773

PS arghh… you’re not asking about that, are you? In the above example, I think the ...: is just a continuation / alignment thing showing the lines continue as part of the In[]: block?

1 Like

Yes ...: is just line continuation in iPython so you can right fuctions/indented blocks as if it was a script rather than a command line.

1 Like