Nextjournal's default Python environment contains several packages for data manipulation and parsing.
The SciPy ecosystem is available, including scipy version, numpy, and pandas.
simplejson makes it easy to encode/decode JSON data structures.
six is included to help smooth differences between Python 2 and 3.
Numpy's main object is a N-dimensional array useful for linear algebra, Fourier transforms, and random number capabilities. Here it is used to create a Mandelbrot set which is ultimately plotted using matplotlib.
defmandelbrot( h,w, maxit=10):
y,x=np.ogrid[ -1.4:1.4:h*1j, -2:0.8:w*1j ]
diverge=z*np.conj(z) >2**2# who is diverging
div_now=diverge& (divtime==maxit) # who is diverging now
divtime[div_now] =i+100# note when
z[diverge] =2# avoid diverging too much
Python 3 Tests (Python)
Pandas makes data analysis easier with Python. For example, a single instantiation of pandas' Series class can include all label and data information. 996 random values are generated by numpy and the final graph is plotted with matplotlib.
Six makes it easy to write Python code that is compatible with both Python 2 and Python 3.
For example, Python 2's urllib, urllib2, and urlparse modules have been combined in the urllib package in Python 3. The six.moves.urllib package is a version-independent location for this functionality.
Python 2 Tests (Python)
Python 3 Tests (Python)
# Converting Pandas Dataframe to Apache Arrow Table
Add conda's library directory so ldconfig will pick it up, set conda config, and ensure pip is reasonably updated. We also pin Python to the installed minor version, allowing only patch-version up/downgrades.
# make this the last alphabetically => lowest precedence libraries
This default image has support for a number of general-use packages, including pandas, scipy, scikit-learn, scikit-image, and opencv-python. For graphical output, matplotlib and plotly are installed. We'll also install some basic utilities, as well as setuptools to make any additional installs less difficult. We're installing Jedi to have code completions for Python, and Jupyter to support notebook imports.
Installing the dev version of jupyter-core to address an issue with connection file permissions. Change to plain pip upgrade of jupyter-core once v4.6.2 is released. –MPD, 26 Nov 2019
conda install -c plotly \
setuptools six simplejson dill pillow pytables h5py \