diff --git a/doc/source/tutorial.rst b/doc/source/tutorial.rst
index 18e680ca3..cfb8a1677 100644
--- a/doc/source/tutorial.rst
+++ b/doc/source/tutorial.rst
@@ -12,7 +12,7 @@ It is mainly dedicated to help new users to familiarize with it and others to re
.. toctree::
:maxdepth: 2
- ./tutorial/getting_started.rst
+ ./tutorial/getting_started.ipynb
./tutorial/tutorial_presenting_larray_objects.ipynb
./tutorial/tutorial_IO.ipynb
./tutorial/tutorial_transforming.ipynb
@@ -22,4 +22,4 @@ It is mainly dedicated to help new users to familiarize with it and others to re
./tutorial/tutorial_plotting.ipynb
./tutorial/tutorial_miscellaneous.ipynb
./tutorial/tutorial_sessions.ipynb
- ./tutorial/pandas.rst
+ ./tutorial/pandas.ipynb
diff --git a/doc/source/tutorial/getting_started.ipyml b/doc/source/tutorial/getting_started.ipyml
new file mode 100644
index 000000000..133941efd
--- /dev/null
+++ b/doc/source/tutorial/getting_started.ipyml
@@ -0,0 +1,529 @@
+cells:
+
+- markdown: |
+ # Getting Started
+
+
+- markdown: |
+ The purpose of the present **Getting Started** section is to give a quick overview
+ of the main objects and features of the LArray library.
+ To get a more detailed presentation of all capabilities of LArray, read the next sections of the tutorial.
+
+ The [API Reference](../api.rst#api-reference) section of the documentation give you the list of all objects, methods and functions with their individual documentation and examples.
+
+ To use the LArray library, the first thing to do is to import it:
+
+
+- code: |
+ from larray import *
+
+
+- markdown: |
+ To know the version of the LArray library installed on your machine, type:
+
+
+- code: |
+ from larray import __version__
+ __version__
+
+
+- markdown: |
+ ## Create an array
+
+
+- markdown: |
+ Working with the LArray library mainly consists of manipulating [Array](../api.rst#array) data structures.
+ They represent N-dimensional labelled arrays and are composed of raw data (NumPy ndarray), axes and optionally some metadata.
+
+ An [Axis](../api.rst#axis) object represents a dimension of an array. It contains a list of labels and has a name:
+
+
+- code: |
+ # define some axes to be used later
+ age = Axis(['0-9', '10-17', '18-66', '67+'], 'age')
+ gender = Axis(['female', 'male'], 'gender')
+ time = Axis([2015, 2016, 2017], 'time')
+
+
+- markdown: |
+ The labels allow to select subsets and to manipulate the data without working with the positions
+ of array elements directly.
+
+ To create an array from scratch, you need to supply data and axes:
+
+
+- code: |
+ # define some data. This is the belgian population (in thousands). Source: eurostat.
+ data = [[[633, 635, 634],
+ [663, 665, 664]],
+ [[484, 486, 491],
+ [505, 511, 516]],
+ [[3572, 3581, 3583],
+ [3600, 3618, 3616]],
+ [[1023, 1038, 1053],
+ [756, 775, 793]]]
+
+ # create an Array object
+ pop = Array(data, axes=[age, gender, time])
+ pop
+
+
+- markdown: |
+ You can optionally attach some metadata to an array:
+
+
+- code: |
+ # attach some metadata to the pop array
+ pop.meta.title = 'population by age, sex and year'
+ pop.meta.source = 'Eurostat'
+
+ # display metadata
+ pop.meta
+
+
+- markdown: |
+ To get a short summary of an array, type:
+
+
+- code: |
+ # Array summary: metadata + dimensions + description of axes
+ pop.info
+
+
+- markdown: |
+ ## Create an array filled with predefined values
+
+
+- markdown: |
+ Arrays filled with predefined values can be generated through [dedicated functions](../api.rst#array-creation-functions):
+
+ - `zeros` : creates an array filled with 0
+ - `ones` : creates an array filled with 1
+ - `full` : creates an array filled with a given value
+ - `sequence` : creates an array by sequentially applying modifications to the array along axis.
+ - `ndtest` : creates a test array with increasing numbers as data
+
+
+- code: |
+ zeros([age, gender])
+
+
+- code: |
+ ones([age, gender])
+
+
+- code: |
+ full([age, gender], fill_value=10.0)
+
+
+- code: |
+ sequence(age)
+
+
+- code: |
+ ndtest([age, gender])
+
+
+- markdown: |
+ ## Save/Load an array
+
+
+- markdown: |
+ The LArray library offers many I/O functions to read and write arrays in various formats
+ (CSV, Excel, HDF5). For example, to save an array in a CSV file, call the method `to_csv`:
+
+
+- code: |
+ # save our pop array to a CSV file
+ pop.to_csv('belgium_pop.csv')
+
+
+- markdown: |
+ The content of the CSV file is then:
+
+ age,gender\time,2015,2016,2017
+ 0-9,female,633,635,634
+ 0-9,male,663,665,664
+ 10-17,female,484,486,491
+ 10-17,male,505,511,516
+ 18-66,female,3572,3581,3583
+ 18-66,male,3600,3618,3616
+ 67+,female,1023,1038,1053
+ 67+,male,756,775,793
+
+
+- markdown: |
+
+ Note: In CSV or Excel files, the last dimension is horizontal and the names of the
+ last two dimensions are separated by a backslash \.
+
+
+
+- markdown: |
+ To load a saved array, call the function `read_csv`:
+
+
+- code: |
+ pop = read_csv('belgium_pop.csv')
+ pop
+
+
+- markdown: |
+ Other input/output functions are described in the [Input/Output](../api.rst#input-output) section of the API documentation.
+
+
+- markdown: |
+ ## Selecting a subset
+
+
+- markdown: |
+ To select an element or a subset of an array, use brackets [ ].
+ In Python we usually use the term *indexing* for this operation.
+
+ Let us start by selecting a single element:
+
+
+- code: |
+ pop['67+', 'female', 2017]
+
+
+- markdown: |
+ Labels can be given in arbitrary order:
+
+
+- code: |
+ pop[2017, 'female', '67+']
+
+
+- markdown: |
+ When selecting a larger subset the result is an array:
+
+
+- code: |
+ pop['female']
+
+
+- markdown: |
+ When selecting several labels for the same axis, they must be given as a list (enclosed by ``[ ]``)
+
+
+- code: |
+ pop['female', ['0-9', '10-17']]
+
+
+- markdown: |
+ You can also select *slices*, which are all labels between two bounds (we usually call them the `start` and `stop`
+ bounds). Specifying the `start` and `stop` bounds of a slice is optional: when not given, `start` is the first label
+ of the corresponding axis, `stop` the last one:
+
+
+- code: |
+ # in this case '10-17':'67+' is equivalent to ['10-17', '18-66', '67+']
+ pop['female', '10-17':'67+']
+
+
+- code: |
+ # :'18-66' selects all labels between the first one and '18-66'
+ # 2017: selects all labels between 2017 and the last one
+ pop[:'18-66', 2017:]
+
+
+- markdown: |
+
+ Note: Contrary to slices on normal Python lists, the stop bound is included in the selection.
+
+
+
+- markdown: |
+
+ Selecting by labels as above only works as long as there is no ambiguity.
+ When several axes have some labels in common and you do not specify explicitly
+ on which axis to work, it fails with an error ending with something like
+
+ ValueError:
is ambiguous (valid in , ).
+
+
+
+- markdown: |
+ For example, imagine you need to work with an 'immigration' array containing two axes sharing some common labels:
+
+
+- code: |
+ country = Axis(['Belgium', 'Netherlands', 'Germany'], 'country')
+ citizenship = Axis(['Belgium', 'Netherlands', 'Germany'], 'citizenship')
+
+ immigration = ndtest((country, citizenship, time))
+
+ immigration
+
+
+- markdown: |
+ If we try to get the number of Belgians living in the Netherlands for the year 2017, we might try something like:
+
+
+- markdown: |
+ ```python
+ immigration['Netherlands', 'Belgium', 2017]
+ ```
+
+
+- markdown: |
+ ... but we receive back a volley of insults:
+
+
+- markdown: |
+ ```
+ [some long error message ending with the line below]
+ [...]
+ ValueError: Netherlands is ambiguous (valid in country, citizenship)
+ ```
+
+
+- markdown: |
+ In that case, we have to specify explicitly which axes the 'Netherlands' and 'Belgium' labels we want to select belong to:
+
+
+- code: |
+ immigration[country['Netherlands'], citizenship['Belgium'], 2017]
+
+
+- markdown: |
+ ## Aggregation
+
+
+- markdown: |
+ The LArray library includes many [aggregations methods](../api.rst#aggregation-functions): sum, mean, min, max, std, var, ...
+
+ For example, assuming we still have an array in the ``pop`` variable:
+
+
+- code: |
+ pop
+
+
+- markdown: |
+ We can sum along the 'sex' axis using:
+
+
+- code: |
+ pop.sum(gender)
+
+
+- markdown: |
+ Or sum along both 'age' and 'sex':
+
+
+- code: |
+ pop.sum(age, gender)
+
+
+- markdown: |
+ It is sometimes more convenient to aggregate along all axes **except** some. In that case, use the aggregation
+ methods ending with `_by`. For example:
+
+
+- code: |
+ pop.sum_by(time)
+
+
+- markdown: |
+ ## Groups
+
+
+- markdown: |
+ A [Group](../api.rst#group) object represents a subset of labels or positions of an axis:
+
+
+- code: |
+ children = age['0-9', '10-17']
+ children
+
+
+- markdown: |
+ It is often useful to attach them an explicit name using the ``>>`` operator:
+
+
+- code: |
+ working = age['18-66'] >> 'working'
+ working
+
+
+- code: |
+ nonworking = age['0-9', '10-17', '67+'] >> 'nonworking'
+ nonworking
+
+
+- markdown: |
+ Still using the same ``pop`` array:
+
+
+- code: |
+ pop
+
+
+- markdown: |
+ Groups can be used in selections:
+
+
+- code: |
+ pop[working]
+
+
+- code: |
+ pop[nonworking]
+
+
+- markdown: |
+ or aggregations:
+
+
+- code: |
+ pop.sum(nonworking)
+
+
+- markdown: |
+ When aggregating several groups, the names we set above using ``>>`` determines the label on the aggregated axis.
+ Since we did not give a name for the children group, the resulting label is generated automatically :
+
+
+- code: |
+ pop.sum((children, working, nonworking))
+
+
+- markdown: |
+ ## Grouping arrays in a Session
+
+
+- markdown: |
+ Arrays may be grouped in [Session](../api.rst#session) objects.
+ A session is an ordered dict-like container of Array objects with special I/O methods.
+ To create a session, you need to pass a list of pairs (array_name, array):
+
+
+- code: |
+ pop = zeros([age, gender, time])
+ births = zeros([age, gender, time])
+ deaths = zeros([age, gender, time])
+
+ # create a session containing the three arrays 'pop', 'births' and 'deaths'
+ demo = Session(pop=pop, births=births, deaths=deaths)
+
+ # displays names of arrays contained in the session
+ demo.names
+ # get an array
+ demo['pop']
+ # add/modify an array
+ demo['foreigners'] = zeros([age, gender, time])
+
+
+- markdown: |
+
+ If you are using a Python version prior to 3.6, you will have to pass a list of pairs
+ to the Session constructor otherwise the arrays will be stored in an arbitrary order in
+ the new session. For example, the session above must be created using the syntax:
+
+ `demo=Session([('pop', pop), ('births', births), ('deaths', deaths)])`.
+
+
+
+- markdown: |
+ One of the main interests of using sessions is to save and load many arrays at once:
+
+
+- code: |
+ # dump all arrays contained in the session 'demo' in one HDF5 file
+ demo.save('demo.h5')
+ # load all arrays saved in the HDF5 file 'demo.h5' and store them in the session 'demo'
+ demo = Session('demo.h5')
+
+
+- markdown: |
+ ## Graphical User Interface (viewer)
+
+
+- markdown: |
+ The LArray project provides an optional package called [larray-editor](../api.rst#editor) allowing users to explore and edit arrays through a graphical interface.
+
+ The larray-editor tool is automatically available when installing the **larrayenv** metapackage from conda.
+
+ To explore the content of arrays in read-only mode, call the `view` function:
+
+
+- markdown: |
+ ```python
+ # shows the arrays of a given session in a graphical user interface
+ view(demo)
+
+ # the session may be directly loaded from a file
+ view('demo.h5')
+
+ # creates a session with all existing arrays from the current namespace
+ # and shows its content
+ view()
+ ```
+
+
+- markdown: |
+ To open the user interface in edit mode, call the `edit` function instead.
+
+ 
+
+
+- markdown: |
+ Finally, you can also visually compare two arrays or sessions using the `compare` function:
+
+
+- markdown: |
+ ```python
+ arr0 = ndtest((3, 3))
+ arr1 = ndtest((3, 3))
+ arr1[['a1', 'a2']] = -arr1[['a1', 'a2']]
+ compare(arr0, arr1)
+ ```
+
+
+- markdown: |
+ 
+
+
+- markdown: |
+ ### For Windows Users
+
+
+- markdown: |
+ Installing the ``larray-editor`` package on Windows will create a ``LArray`` menu in the
+ Windows Start Menu. This menu contains:
+
+ * a shortcut to open the documentation of the last stable version of the library
+ * a shortcut to open the graphical interface in edit mode.
+ * a shortcut to update `larrayenv`.
+
+ 
+
+ 
+
+ Once the graphical interface is open, all LArray objects and functions are directly accessible.
+ No need to start by `from larray import *`.
+
+
+# The lines below here may be deleted if you do not need them.
+# ---------------------------------------------------------------------------
+metadata:
+ celltoolbar: Edit Metadata
+ kernelspec:
+ display_name: Python 3
+ language: python
+ name: python3
+ language_info:
+ codemirror_mode:
+ name: ipython
+ version: 3
+ file_extension: .py
+ mimetype: text/x-python
+ name: python
+ nbconvert_exporter: python
+ pygments_lexer: ipython3
+ version: 3.7.3
+nbformat: 4
+nbformat_minor: 2
+
diff --git a/doc/source/tutorial/getting_started.ipynb b/doc/source/tutorial/getting_started.ipynb
new file mode 100644
index 000000000..7a8a79819
--- /dev/null
+++ b/doc/source/tutorial/getting_started.ipynb
@@ -0,0 +1,872 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Getting Started"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "The purpose of the present **Getting Started** section is to give a quick overview\n",
+ "of the main objects and features of the LArray library.\n",
+ "To get a more detailed presentation of all capabilities of LArray, read the next sections of the tutorial.\n",
+ "\n",
+ "The [API Reference](../api.rst#api-reference) section of the documentation give you the list of all objects, methods and functions with their individual documentation and examples.\n",
+ "\n",
+ "To use the LArray library, the first thing to do is to import it:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from larray import *"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "To know the version of the LArray library installed on your machine, type:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from larray import __version__\n",
+ "__version__"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Create an array"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Working with the LArray library mainly consists of manipulating [Array](../api.rst#array) data structures.\n",
+ "They represent N-dimensional labelled arrays and are composed of raw data (NumPy ndarray), axes and optionally some metadata.\n",
+ "\n",
+ "An [Axis](../api.rst#axis) object represents a dimension of an array. It contains a list of labels and has a name:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# define some axes to be used later\n",
+ "age = Axis(['0-9', '10-17', '18-66', '67+'], 'age')\n",
+ "gender = Axis(['female', 'male'], 'gender')\n",
+ "time = Axis([2015, 2016, 2017], 'time')"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "The labels allow to select subsets and to manipulate the data without working with the positions\n",
+ "of array elements directly.\n",
+ "\n",
+ "To create an array from scratch, you need to supply data and axes:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# define some data. This is the belgian population (in thousands). Source: eurostat.\n",
+ "data = [[[633, 635, 634],\n",
+ " [663, 665, 664]],\n",
+ " [[484, 486, 491],\n",
+ " [505, 511, 516]],\n",
+ " [[3572, 3581, 3583],\n",
+ " [3600, 3618, 3616]],\n",
+ " [[1023, 1038, 1053],\n",
+ " [756, 775, 793]]]\n",
+ "\n",
+ "# create an Array object\n",
+ "pop = Array(data, axes=[age, gender, time])\n",
+ "pop"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "You can optionally attach some metadata to an array:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# attach some metadata to the pop array\n",
+ "pop.meta.title = 'population by age, sex and year'\n",
+ "pop.meta.source = 'Eurostat'\n",
+ "\n",
+ "# display metadata\n",
+ "pop.meta"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "To get a short summary of an array, type:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# Array summary: metadata + dimensions + description of axes\n",
+ "pop.info"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Create an array filled with predefined values"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Arrays filled with predefined values can be generated through [dedicated functions](../api.rst#array-creation-functions):\n",
+ "\n",
+ " - `zeros` : creates an array filled with 0\n",
+ " - `ones` : creates an array filled with 1\n",
+ " - `full` : creates an array filled with a given value\n",
+ " - `sequence` : creates an array by sequentially applying modifications to the array along axis.\n",
+ " - `ndtest` : creates a test array with increasing numbers as data"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "zeros([age, gender])"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "ones([age, gender])"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "full([age, gender], fill_value=10.0)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "sequence(age)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "ndtest([age, gender])"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Save/Load an array"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "The LArray library offers many I/O functions to read and write arrays in various formats\n",
+ "(CSV, Excel, HDF5). For example, to save an array in a CSV file, call the method `to_csv`:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# save our pop array to a CSV file\n",
+ "pop.to_csv('belgium_pop.csv')"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "The content of the CSV file is then:\n",
+ "\n",
+ " age,gender\\time,2015,2016,2017\n",
+ " 0-9,female,633,635,634\n",
+ " 0-9,male,663,665,664\n",
+ " 10-17,female,484,486,491\n",
+ " 10-17,male,505,511,516\n",
+ " 18-66,female,3572,3581,3583\n",
+ " 18-66,male,3600,3618,3616\n",
+ " 67+,female,1023,1038,1053\n",
+ " 67+,male,756,775,793 "
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ " Note: In CSV or Excel files, the last dimension is horizontal and the names of the\n",
+ " last two dimensions are separated by a backslash \\.\n",
+ "
"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "To load a saved array, call the function `read_csv`:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "pop = read_csv('belgium_pop.csv')\n",
+ "pop"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Other input/output functions are described in the [Input/Output](../api.rst#input-output) section of the API documentation."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Selecting a subset"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "To select an element or a subset of an array, use brackets [ ].\n",
+ "In Python we usually use the term *indexing* for this operation.\n",
+ "\n",
+ "Let us start by selecting a single element:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "pop['67+', 'female', 2017]"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Labels can be given in arbitrary order:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "pop[2017, 'female', '67+']"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "When selecting a larger subset the result is an array:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "pop['female']"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "When selecting several labels for the same axis, they must be given as a list (enclosed by ``[ ]``)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "pop['female', ['0-9', '10-17']]"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "You can also select *slices*, which are all labels between two bounds (we usually call them the `start` and `stop`\n",
+ "bounds). Specifying the `start` and `stop` bounds of a slice is optional: when not given, `start` is the first label\n",
+ "of the corresponding axis, `stop` the last one:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# in this case '10-17':'67+' is equivalent to ['10-17', '18-66', '67+']\n",
+ "pop['female', '10-17':'67+']"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# :'18-66' selects all labels between the first one and '18-66'\n",
+ "# 2017: selects all labels between 2017 and the last one\n",
+ "pop[:'18-66', 2017:]"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ " Note: Contrary to slices on normal Python lists, the stop bound is included in the selection.\n",
+ "
"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ " Selecting by labels as above only works as long as there is no ambiguity.\n",
+ " When several axes have some labels in common and you do not specify explicitly\n",
+ " on which axis to work, it fails with an error ending with something like\n",
+ " \n",
+ " ValueError:
is ambiguous (valid in , ).\n",
+ " "
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "For example, imagine you need to work with an 'immigration' array containing two axes sharing some common labels:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "country = Axis(['Belgium', 'Netherlands', 'Germany'], 'country')\n",
+ "citizenship = Axis(['Belgium', 'Netherlands', 'Germany'], 'citizenship')\n",
+ "\n",
+ "immigration = ndtest((country, citizenship, time))\n",
+ "\n",
+ "immigration"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "If we try to get the number of Belgians living in the Netherlands for the year 2017, we might try something like:"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "```python\n",
+ " immigration['Netherlands', 'Belgium', 2017]\n",
+ "```"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "... but we receive back a volley of insults:"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "```\n",
+ " [some long error message ending with the line below]\n",
+ " [...]\n",
+ " ValueError: Netherlands is ambiguous (valid in country, citizenship)\n",
+ "```"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "In that case, we have to specify explicitly which axes the 'Netherlands' and 'Belgium' labels we want to select belong to:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "immigration[country['Netherlands'], citizenship['Belgium'], 2017]"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Aggregation"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "The LArray library includes many [aggregations methods](../api.rst#aggregation-functions): sum, mean, min, max, std, var, ...\n",
+ "\n",
+ "For example, assuming we still have an array in the ``pop`` variable:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "pop"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "We can sum along the 'sex' axis using:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "pop.sum(gender)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Or sum along both 'age' and 'sex':"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "pop.sum(age, gender)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "It is sometimes more convenient to aggregate along all axes **except** some. In that case, use the aggregation\n",
+ "methods ending with `_by`. For example:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "pop.sum_by(time)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Groups"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "A [Group](../api.rst#group) object represents a subset of labels or positions of an axis:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "children = age['0-9', '10-17']\n",
+ "children"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "It is often useful to attach them an explicit name using the ``>>`` operator:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "working = age['18-66'] >> 'working'\n",
+ "working"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "nonworking = age['0-9', '10-17', '67+'] >> 'nonworking'\n",
+ "nonworking"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Still using the same ``pop`` array:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "pop"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Groups can be used in selections:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "pop[working]"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "pop[nonworking]"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "or aggregations:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "pop.sum(nonworking)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "When aggregating several groups, the names we set above using ``>>`` determines the label on the aggregated axis.\n",
+ "Since we did not give a name for the children group, the resulting label is generated automatically :"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "pop.sum((children, working, nonworking))"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Grouping arrays in a Session"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Arrays may be grouped in [Session](../api.rst#session) objects.\n",
+ "A session is an ordered dict-like container of Array objects with special I/O methods.\n",
+ "To create a session, you need to pass a list of pairs (array_name, array):"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "pop = zeros([age, gender, time])\n",
+ "births = zeros([age, gender, time])\n",
+ "deaths = zeros([age, gender, time])\n",
+ "\n",
+ "# create a session containing the three arrays 'pop', 'births' and 'deaths'\n",
+ "demo = Session(pop=pop, births=births, deaths=deaths)\n",
+ "\n",
+ "# displays names of arrays contained in the session\n",
+ "demo.names\n",
+ "# get an array\n",
+ "demo['pop']\n",
+ "# add/modify an array\n",
+ "demo['foreigners'] = zeros([age, gender, time])"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ " If you are using a Python version prior to 3.6, you will have to pass a list of pairs\n",
+ " to the Session constructor otherwise the arrays will be stored in an arbitrary order in\n",
+ " the new session. For example, the session above must be created using the syntax:\n",
+ " \n",
+ " `demo=Session([('pop', pop), ('births', births), ('deaths', deaths)])`.\n",
+ "
"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "One of the main interests of using sessions is to save and load many arrays at once:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# dump all arrays contained in the session 'demo' in one HDF5 file\n",
+ "demo.save('demo.h5')\n",
+ "# load all arrays saved in the HDF5 file 'demo.h5' and store them in the session 'demo'\n",
+ "demo = Session('demo.h5')"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Graphical User Interface (viewer)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "The LArray project provides an optional package called [larray-editor](../api.rst#editor) allowing users to explore and edit arrays through a graphical interface.\n",
+ "\n",
+ "The larray-editor tool is automatically available when installing the **larrayenv** metapackage from conda.\n",
+ "\n",
+ "To explore the content of arrays in read-only mode, call the `view` function:"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "```python\n",
+ " # shows the arrays of a given session in a graphical user interface\n",
+ " view(demo)\n",
+ "\n",
+ " # the session may be directly loaded from a file\n",
+ " view('demo.h5')\n",
+ "\n",
+ " # creates a session with all existing arrays from the current namespace\n",
+ " # and shows its content\n",
+ " view()\n",
+ "```"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "To open the user interface in edit mode, call the `edit` function instead.\n",
+ "\n",
+ ""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Finally, you can also visually compare two arrays or sessions using the `compare` function:"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "```python\n",
+ " arr0 = ndtest((3, 3))\n",
+ " arr1 = ndtest((3, 3))\n",
+ " arr1[['a1', 'a2']] = -arr1[['a1', 'a2']]\n",
+ " compare(arr0, arr1)\n",
+ "```"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ ""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### For Windows Users"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Installing the ``larray-editor`` package on Windows will create a ``LArray`` menu in the\n",
+ "Windows Start Menu. This menu contains:\n",
+ "\n",
+ " * a shortcut to open the documentation of the last stable version of the library\n",
+ " * a shortcut to open the graphical interface in edit mode.\n",
+ " * a shortcut to update `larrayenv`.\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "Once the graphical interface is open, all LArray objects and functions are directly accessible.\n",
+ "No need to start by `from larray import *`."
+ ]
+ }
+ ],
+ "metadata": {
+ "celltoolbar": "Edit Metadata",
+ "kernelspec": {
+ "display_name": "Python 3",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.7.3"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}
diff --git a/doc/source/tutorial/getting_started.rst b/doc/source/tutorial/getting_started.rst
deleted file mode 100644
index b111b6da7..000000000
--- a/doc/source/tutorial/getting_started.rst
+++ /dev/null
@@ -1,421 +0,0 @@
-.. currentmodule:: larray
-
-Getting Started
-===============
-
-The purpose of the present **Getting Started** section is to give a quick overview
-of the main objects and features of the LArray library.
-To get a more detailed presentation of all capabilities of LArray, read the
-next sections of the tutorial.
-The :ref:`API Reference ` section of the documentation give you the list
-of all objects, methods and functions with their individual documentation and examples.
-
-To use the LArray library, the first thing to do is to import it:
-
-.. ipython:: python
-
- from larray import *
-
-Create an array
----------------
-
-Working with the LArray library mainly consists of manipulating :ref:`Array ` data structures.
-They represent N-dimensional labelled arrays and are composed of raw data (NumPy ndarray), :ref:`axes `
-and optionally some metadata.
-
-An axis represents a dimension of an array. It contains a list of labels and has a name:
-
-.. ipython:: python
-
- # define some axes to be used later
- age = Axis(['0-9', '10-17', '18-66', '67+'], 'age')
- sex = Axis(['F', 'M'], 'sex')
- year = Axis([2015, 2016, 2017], 'year')
-
-The labels allow to select subsets and to manipulate the data without working with the positions
-of array elements directly.
-
-To create an array from scratch, you need to supply data and axes:
-
-.. ipython:: python
-
- # define some data. This is the belgian population (in thousands). Source: eurostat.
- data = [[[633, 635, 634],
- [663, 665, 664]],
- [[484, 486, 491],
- [505, 511, 516]],
- [[3572, 3581, 3583],
- [3600, 3618, 3616]],
- [[1023, 1038, 1053],
- [756, 775, 793]]]
-
- # create an Array object
- pop = Array(data, axes=[age, sex, year])
- pop
-
-You can optionally attach some metadata to an array:
-
-.. ipython:: python
-
- # attach some metadata to the pop array
- pop.meta.title = 'population by age, sex and year'
- pop.meta.source = 'Eurostat'
-
- # display metadata
- pop.meta
-
-To get a short summary of an array, type:
-
-.. ipython:: python
-
- # Array summary: metadata + dimensions + description of axes
- pop.info
-
-
-Create an array filled with predefined values
----------------------------------------------
-
-Arrays filled with predefined values can be generated through dedicated functions:
-
-* :py:func:`zeros` : creates an array filled with 0
-
-.. ipython:: python
-
- zeros([age, sex])
-
-* :py:func:`ones` : creates an array filled with 1
-
-.. ipython:: python
-
- ones([age, sex])
-
-* :py:func:`full` : creates an array filled with a given value
-
-.. ipython:: python
-
- full([age, sex], fill_value=10.0)
-
-* :py:func:`sequence` : creates an array by sequentially applying modifications to the array along axis.
-
-.. ipython:: python
-
- sequence(age)
-
-* :py:func:`ndtest` : creates a test array with increasing numbers as data
-
-.. ipython:: python
-
- ndtest([age, sex])
-
-
-Save/Load an array
-------------------
-
-The LArray library offers many I/O functions to read and write arrays in various formats
-(CSV, Excel, HDF5). For example, to save an array in a CSV file, call the method
-:py:meth:`~Array.to_csv`:
-
-.. ipython:: python
-
- # save our pop array to a CSV file
- pop.to_csv('belgium_pop.csv')
-
-The content of the CSV file is then::
-
- age,sex\time,2015,2016,2017
- 0-9,F,633,635,634
- 0-9,M,663,665,664
- 10-17,F,484,486,491
- 10-17,M,505,511,516
- 18-66,F,3572,3581,3583
- 18-66,M,3600,3618,3616
- 67+,F,1023,1038,1053
- 67+,M,756,775,793
-
-.. note::
- In CSV or Excel files, the last dimension is horizontal and the names of the
- last two dimensions are separated by a ``\``.
-
-To load a saved array, call the function :py:meth:`read_csv`:
-
-.. ipython:: python
-
- pop = read_csv('belgium_pop.csv')
- pop
-
-Other input/output functions are described in the :ref:`Input/Output ` section of the API documentation.
-
-Selecting a subset
-------------------
-
-To select an element or a subset of an array, use brackets [ ].
-In Python we usually use the term *indexing* for this operation.
-
-Let us start by selecting a single element:
-
-.. ipython:: python
-
- pop['67+', 'F', 2017]
-
-Labels can be given in arbitrary order:
-
-.. ipython:: python
-
- pop[2017, 'F', '67+']
-
-When selecting a larger subset the result is an array:
-
-.. ipython:: python
-
- pop[2017]
- pop['M']
-
-When selecting several labels for the same axis, they must be given as a list (enclosed by ``[ ]``)
-
-.. ipython:: python
-
- pop['F', ['0-9', '10-17']]
-
-You can also select *slices*, which are all labels between two bounds (we usually call them the `start` and `stop`
-bounds). Specifying the `start` and `stop` bounds of a slice is optional: when not given, `start` is the first label
-of the corresponding axis, `stop` the last one:
-
-.. ipython:: python
-
- # in this case '10-17':'67+' is equivalent to ['10-17', '18-66', '67+']
- pop['F', '10-17':'67+']
-
- # :'18-66' selects all labels between the first one and '18-66'
- # 2017: selects all labels between 2017 and the last one
- pop[:'18-66', 2017:]
-
-.. note::
- Contrary to slices on normal Python lists, the ``stop`` bound **is** included in the selection.
-
-.. warning::
-
- Selecting by labels as above only works as long as there is no ambiguity.
- When several axes have some labels in common and you do not specify explicitly
- on which axis to work, it fails with an error ending with something like
- ValueError: is ambiguous (valid in , ).
-
-For example, let us create a test array with an ambiguous label. We first create an axis (some kind of status code)
-with an 'F' label (remember we already have an 'F' label on the sex axis).
-
-.. ipython:: python
-
- status = Axis(['A', 'C', 'F'], 'status')
-
-Then create a test array using both axes 'sex' and 'status':
-
-.. ipython:: python
-
- ambiguous_arr = ndtest([sex, status, year])
- ambiguous_arr
-
-If we try to get the subset of our array concerning women (represented by the 'F' label in our array), we might
-try something like:
-
-.. ipython:: python
- :verbatim:
-
- ambiguous_arr[2017, 'F']
-
-... but we receive back a volley of insults ::
-
- [some long error message ending with the line below]
- [...]
- ValueError: F is ambiguous (valid in sex, status)
-
-In that case, we have to specify explicitly which axis the 'F' label we want to select belongs to:
-
-.. ipython:: python
-
- ambiguous_arr[2017, sex['F']]
-
-
-Aggregation
------------
-
-The LArray library includes many :ref:`aggregations methods `: sum, mean, min, max, std, var, ...
-
-For example, assuming we still have an array in the ``pop`` variable:
-
-.. ipython:: python
-
- pop
-
-We can sum along the 'sex' axis using:
-
-.. ipython:: python
-
- pop.sum(sex)
-
-Or sum along both 'age' and 'sex':
-
-.. ipython:: python
-
- pop.sum(age, sex)
-
-It is sometimes more convenient to aggregate along all axes **except** some. In that case, use the aggregation
-methods ending with `_by`. For example:
-
-.. ipython:: python
-
- pop.sum_by(year)
-
-
-Groups
-------
-
-A :ref:`Group ` represents a subset of labels or positions of an axis:
-
-
-.. ipython:: python
-
- children = age['0-9', '10-17']
- children
-
-It is often useful to attach them an explicit name using the ``>>`` operator:
-
-.. ipython:: python
-
- working = age['18-66'] >> 'working'
- working
-
- nonworking = age['0-9', '10-17', '67+'] >> 'nonworking'
- nonworking
-
-Still using the same ``pop`` array:
-
-.. ipython:: python
-
- pop
-
-Groups can be used in selections:
-
-.. ipython:: python
-
- pop[working]
- pop[nonworking]
-
-or aggregations:
-
-.. ipython:: python
-
- pop.sum(nonworking)
-
-When aggregating several groups, the names we set above using ``>>`` determines the label on the aggregated axis.
-Since we did not give a name for the children group, the resulting label is generated automatically :
-
-.. ipython:: python
-
- pop.sum((children, working, nonworking))
-
-
-Grouping arrays in a Session
-----------------------------
-
-Arrays may be grouped in :ref:`Session ` objects.
-A session is an ordered dict-like container of Array objects with special I/O methods.
-To create a session, you need to pass a list of pairs (array_name, array):
-
-.. ipython:: python
-
- pop = zeros([age, sex, year])
- births = zeros([age, sex, year])
- deaths = zeros([age, sex, year])
-
- # create a session containing the three arrays 'pop', 'births' and 'deaths'
- demo = Session(pop=pop, births=births, deaths=deaths)
-
- # displays names of arrays contained in the session
- demo.names
- # get an array
- demo['pop']
- # add/modify an array
- demo['foreigners'] = zeros([age, sex, year])
-
-.. warning::
-
- If you are using a Python version prior to 3.6, you will have to pass a list of pairs
- to the Session constructor otherwise the arrays will be stored in an arbitrary order in
- the new session. For example, the session above must be created using the syntax:
- `demo=Session([('pop', pop), ('births', births), ('deaths', deaths)])`.
-
-One of the main interests of using sessions is to save and load many arrays at once:
-
-.. ipython:: python
- :okwarning:
-
- # dump all arrays contained in the session 'demo' in one HDF5 file
- demo.save('demo.h5')
- # load all arrays saved in the HDF5 file 'demo.h5' and store them in the session 'demo'
- demo = Session('demo.h5')
-
-
-Graphical User Interface (viewer)
----------------------------------
-
-The LArray project provides an optional package called :ref:`larray-editor `
-allowing users to explore and edit arrays through a graphical interface.
-The larray-editor tool is automatically available when installing the **larrayenv** metapackage from conda.
-
-To explore the content of arrays in read-only mode, import ``larray-editor`` and call :py:func:`view`
-
-.. ipython:: python
- :verbatim:
-
- from larray_editor import *
-
- # shows the arrays of a given session in a graphical user interface
- view(ses)
-
- # the session may be directly loaded from a file
- view('my_session.h5')
-
- # creates a session with all existing arrays from the current namespace
- # and shows its content
- view()
-
-To open the user interface in edit mode, call :py:func:`edit` instead.
-
-.. image:: ../_static/editor.png
- :align: center
-
-Once open, you can save and load any session using the `File` menu.
-
-Finally, you can also visually compare two arrays or sessions using the :py:func:`compare` function.
-
-.. ipython:: python
- :verbatim:
-
- arr0 = ndtest((3, 3))
- arr1 = ndtest((3, 3))
- arr1[['a1', 'a2']] = -arr1[['a1', 'a2']]
- compare(arr0, arr1)
-
-.. image:: ../_static/compare.png
- :align: center
-
-In case of two arrays, they must have compatible axes.
-
-For Windows Users
-^^^^^^^^^^^^^^^^^
-
-Installing the ``larray-editor`` package on Windows will create a ``LArray`` menu in the
-Windows Start Menu. This menu contains:
-
- * a shortcut to open the documentation of the last stable version of the library
- * a shortcut to open the graphical interface in edit mode.
- * a shortcut to update `larrayenv`.
-
-.. image:: ../_static/menu_windows.png
- :align: center
-
-.. image:: ../_static/editor_new.png
- :align: center
-
-Once the graphical interface is open, all LArray objects and functions are directly accessible.
-No need to start by `from larray import *`.
-
diff --git a/doc/source/tutorial/pandas.ipyml b/doc/source/tutorial/pandas.ipyml
new file mode 100644
index 000000000..e0355b30a
--- /dev/null
+++ b/doc/source/tutorial/pandas.ipyml
@@ -0,0 +1,58 @@
+cells:
+
+- markdown: |
+ # Compatibility with pandas
+
+
+- markdown: |
+ Import the LArray library:
+
+
+- code: |
+ from larray import *
+
+
+- markdown: |
+ To convert an Array object into a pandas DataFrame, the method [to_frame](../_generated/larray.Array.to_frame.rst#larray.Array.to_frame) can be used:
+
+
+- code: |
+ pop = load_example_data('demography_eurostat').pop
+ pop
+
+
+- code: |
+ df = pop.to_frame()
+ df
+
+
+- markdown: |
+ Inversely, to convert a DataFrame into an Array object, use the function [asarray](../_generated/larray.asarray.rst#larray.asarray):
+
+
+- code: |
+ pop = asarray(df)
+ pop
+
+
+# The lines below here may be deleted if you do not need them.
+# ---------------------------------------------------------------------------
+metadata:
+ celltoolbar: Edit Metadata
+ kernelspec:
+ display_name: Python 3
+ language: python
+ name: python3
+ language_info:
+ codemirror_mode:
+ name: ipython
+ version: 3
+ file_extension: .py
+ mimetype: text/x-python
+ name: python
+ nbconvert_exporter: python
+ pygments_lexer: ipython3
+ version: 3.7.3
+nbformat: 4
+nbformat_minor: 2
+
diff --git a/doc/source/tutorial/pandas.ipynb b/doc/source/tutorial/pandas.ipynb
new file mode 100644
index 000000000..a9c8f7bde
--- /dev/null
+++ b/doc/source/tutorial/pandas.ipynb
@@ -0,0 +1,93 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Compatibility with pandas"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Import the LArray library:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from larray import *"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "To convert an Array object into a pandas DataFrame, the method [to_frame](../_generated/larray.Array.to_frame.rst#larray.Array.to_frame) can be used:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "pop = load_example_data('demography_eurostat').pop\n",
+ "pop"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "df = pop.to_frame()\n",
+ "df"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Inversely, to convert a DataFrame into an Array object, use the function [asarray](../_generated/larray.asarray.rst#larray.asarray):"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "pop = asarray(df)\n",
+ "pop"
+ ]
+ }
+ ],
+ "metadata": {
+ "celltoolbar": "Edit Metadata",
+ "kernelspec": {
+ "display_name": "Python 3",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.7.3"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}
diff --git a/doc/source/tutorial/pandas.rst b/doc/source/tutorial/pandas.rst
deleted file mode 100644
index 9d23f9635..000000000
--- a/doc/source/tutorial/pandas.rst
+++ /dev/null
@@ -1,16 +0,0 @@
-Compatibility with pandas
-=========================
-
-To convert an Array object into a pandas DataFrame, the method :py:meth:`~Array.to_frame` can be used:
-
-.. ipython:: python
-
- df = pop.to_frame()
- df
-
-Inversely, to convert a DataFrame into an Array object, use the function :py:func:`asarray`:
-
-.. ipython:: python
-
- pop = asarray(df)
- pop
diff --git a/doc/source/tutorial/tutorial_IO.ipyml b/doc/source/tutorial/tutorial_IO.ipyml
index ff325d696..e149522ea 100644
--- a/doc/source/tutorial/tutorial_IO.ipyml
+++ b/doc/source/tutorial/tutorial_IO.ipyml
@@ -8,28 +8,11 @@ cells:
The LArray library provides methods and functions to load and dump Array, Session, Axis Group objects to several formats such as Excel, CSV and HDF5. The HDF5 file format is designed to store and organize large amounts of data. It allows to read and write data much faster than when working with CSV and Excel files.
-- code: |
- # run this cell to avoid annoying warnings
- import warnings
- warnings.filterwarnings("ignore", message=r'.*numpy.dtype size changed*')
-
- metadata:
- nbsphinx: hidden
-
- code: |
# first of all, import the LArray library
from larray import *
-- markdown: |
- Check the version of LArray:
-
-
-- code: |
- from larray import __version__
- __version__
-
-
- markdown: |
## Loading and Dumping Arrays
diff --git a/doc/source/tutorial/tutorial_IO.ipynb b/doc/source/tutorial/tutorial_IO.ipynb
index be0067840..189b107fa 100644
--- a/doc/source/tutorial/tutorial_IO.ipynb
+++ b/doc/source/tutorial/tutorial_IO.ipynb
@@ -14,19 +14,6 @@
"The LArray library provides methods and functions to load and dump Array, Session, Axis Group objects to several formats such as Excel, CSV and HDF5. The HDF5 file format is designed to store and organize large amounts of data. It allows to read and write data much faster than when working with CSV and Excel files. \n"
]
},
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {
- "nbsphinx": "hidden"
- },
- "outputs": [],
- "source": [
- "# run this cell to avoid annoying warnings\n",
- "import warnings\n",
- "warnings.filterwarnings(\"ignore\", message=r'.*numpy.dtype size changed*')"
- ]
- },
{
"cell_type": "code",
"execution_count": null,
@@ -37,23 +24,6 @@
"from larray import *"
]
},
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "Check the version of LArray:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "from larray import __version__\n",
- "__version__"
- ]
- },
{
"cell_type": "markdown",
"metadata": {},
diff --git a/doc/source/tutorial/tutorial_arithmetic_op_and_aggregation.ipyml b/doc/source/tutorial/tutorial_arithmetic_op_and_aggregation.ipyml
index fa260e6a7..ea8d1f8e4 100644
--- a/doc/source/tutorial/tutorial_arithmetic_op_and_aggregation.ipyml
+++ b/doc/source/tutorial/tutorial_arithmetic_op_and_aggregation.ipyml
@@ -4,14 +4,6 @@ cells:
# Arithmetic Operations And Aggregations
-- code: |
- # run this cell to avoid annoying warnings
- import warnings
- warnings.filterwarnings("ignore", message=r'.*numpy.dtype size changed*')
-
- metadata:
- nbsphinx: hidden
-
- markdown: |
Import the LArray library:
@@ -20,15 +12,6 @@ cells:
from larray import *
-- markdown: |
- Check the version of LArray:
-
-
-- code: |
- from larray import __version__
- __version__
-
-
- markdown: |
## Arithmetic operations
diff --git a/doc/source/tutorial/tutorial_arithmetic_op_and_aggregation.ipynb b/doc/source/tutorial/tutorial_arithmetic_op_and_aggregation.ipynb
index eb7ec2ee6..ea5abc98d 100644
--- a/doc/source/tutorial/tutorial_arithmetic_op_and_aggregation.ipynb
+++ b/doc/source/tutorial/tutorial_arithmetic_op_and_aggregation.ipynb
@@ -7,19 +7,6 @@
"# Arithmetic Operations And Aggregations\n"
]
},
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {
- "nbsphinx": "hidden"
- },
- "outputs": [],
- "source": [
- "# run this cell to avoid annoying warnings\n",
- "import warnings\n",
- "warnings.filterwarnings(\"ignore\", message=r'.*numpy.dtype size changed*')"
- ]
- },
{
"cell_type": "markdown",
"metadata": {},
@@ -36,23 +23,6 @@
"from larray import *"
]
},
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "Check the version of LArray:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "from larray import __version__\n",
- "__version__"
- ]
- },
{
"cell_type": "markdown",
"metadata": {},
diff --git a/doc/source/tutorial/tutorial_indexing.ipyml b/doc/source/tutorial/tutorial_indexing.ipyml
index ca14d32f7..597e8eb29 100644
--- a/doc/source/tutorial/tutorial_indexing.ipyml
+++ b/doc/source/tutorial/tutorial_indexing.ipyml
@@ -4,14 +4,6 @@ cells:
# Indexing, Selecting and Assigning
-- code: |
- # run this cell to avoid annoying warnings
- import warnings
- warnings.filterwarnings("ignore", message=r'.*numpy.dtype size changed*')
-
- metadata:
- nbsphinx: hidden
-
- markdown: |
Import the LArray library:
@@ -20,15 +12,6 @@ cells:
from larray import *
-- markdown: |
- Check the version of LArray:
-
-
-- code: |
- from larray import __version__
- __version__
-
-
- markdown: |
Import the test array ``pop``:
diff --git a/doc/source/tutorial/tutorial_indexing.ipynb b/doc/source/tutorial/tutorial_indexing.ipynb
index 0a3261fc0..8ad4fe375 100644
--- a/doc/source/tutorial/tutorial_indexing.ipynb
+++ b/doc/source/tutorial/tutorial_indexing.ipynb
@@ -7,19 +7,6 @@
"# Indexing, Selecting and Assigning\n"
]
},
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {
- "nbsphinx": "hidden"
- },
- "outputs": [],
- "source": [
- "# run this cell to avoid annoying warnings\n",
- "import warnings\n",
- "warnings.filterwarnings(\"ignore\", message=r'.*numpy.dtype size changed*')"
- ]
- },
{
"cell_type": "markdown",
"metadata": {},
@@ -36,23 +23,6 @@
"from larray import *"
]
},
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "Check the version of LArray:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "from larray import __version__\n",
- "__version__"
- ]
- },
{
"cell_type": "markdown",
"metadata": {},
diff --git a/doc/source/tutorial/tutorial_miscellaneous.ipyml b/doc/source/tutorial/tutorial_miscellaneous.ipyml
index 1adfe875b..29320bae6 100644
--- a/doc/source/tutorial/tutorial_miscellaneous.ipyml
+++ b/doc/source/tutorial/tutorial_miscellaneous.ipyml
@@ -4,14 +4,6 @@ cells:
# Some Useful Functions
-- code: |
- # run this cell to avoid annoying warnings
- import warnings
- warnings.filterwarnings("ignore", message=r'.*numpy.dtype size changed*')
-
- metadata:
- nbsphinx: hidden
-
- markdown: |
Import the LArray library:
@@ -20,15 +12,6 @@ cells:
from larray import *
-- markdown: |
- Check the version of LArray:
-
-
-- code: |
- from larray import __version__
- __version__
-
-
- code: |
# load 'demography_eurostat' dataset
demo_eurostat = load_example_data('demography_eurostat')
diff --git a/doc/source/tutorial/tutorial_miscellaneous.ipynb b/doc/source/tutorial/tutorial_miscellaneous.ipynb
index fb3c6d2d9..4e7fb1b4c 100644
--- a/doc/source/tutorial/tutorial_miscellaneous.ipynb
+++ b/doc/source/tutorial/tutorial_miscellaneous.ipynb
@@ -7,19 +7,6 @@
"# Some Useful Functions\n"
]
},
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {
- "nbsphinx": "hidden"
- },
- "outputs": [],
- "source": [
- "# run this cell to avoid annoying warnings\n",
- "import warnings\n",
- "warnings.filterwarnings(\"ignore\", message=r'.*numpy.dtype size changed*')"
- ]
- },
{
"cell_type": "markdown",
"metadata": {},
@@ -36,23 +23,6 @@
"from larray import *"
]
},
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "Check the version of LArray:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "from larray import __version__\n",
- "__version__"
- ]
- },
{
"cell_type": "code",
"execution_count": null,
diff --git a/doc/source/tutorial/tutorial_plotting.ipyml b/doc/source/tutorial/tutorial_plotting.ipyml
index 365d88818..2c5363eb7 100644
--- a/doc/source/tutorial/tutorial_plotting.ipyml
+++ b/doc/source/tutorial/tutorial_plotting.ipyml
@@ -4,14 +4,6 @@ cells:
# Plotting
-- code: |
- # run this cell to avoid annoying warnings
- import warnings
- warnings.filterwarnings("ignore", message=r'.*numpy.dtype size changed*')
-
- metadata:
- nbsphinx: hidden
-
- markdown: |
Import the LArray library:
@@ -20,15 +12,6 @@ cells:
from larray import *
-- markdown: |
- Check the version of LArray:
-
-
-- code: |
- from larray import __version__
- __version__
-
-
- markdown: |
Import a subset of the test array ``pop``:
diff --git a/doc/source/tutorial/tutorial_plotting.ipynb b/doc/source/tutorial/tutorial_plotting.ipynb
index 354cd65cd..f7a1da8d2 100644
--- a/doc/source/tutorial/tutorial_plotting.ipynb
+++ b/doc/source/tutorial/tutorial_plotting.ipynb
@@ -7,19 +7,6 @@
"# Plotting\n"
]
},
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {
- "nbsphinx": "hidden"
- },
- "outputs": [],
- "source": [
- "# run this cell to avoid annoying warnings\n",
- "import warnings\n",
- "warnings.filterwarnings(\"ignore\", message=r'.*numpy.dtype size changed*')"
- ]
- },
{
"cell_type": "markdown",
"metadata": {},
@@ -36,23 +23,6 @@
"from larray import *"
]
},
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "Check the version of LArray:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "from larray import __version__\n",
- "__version__"
- ]
- },
{
"cell_type": "markdown",
"metadata": {},
diff --git a/doc/source/tutorial/tutorial_presenting_larray_objects.ipyml b/doc/source/tutorial/tutorial_presenting_larray_objects.ipyml
index c0e6e3e90..74975e6f6 100644
--- a/doc/source/tutorial/tutorial_presenting_larray_objects.ipyml
+++ b/doc/source/tutorial/tutorial_presenting_larray_objects.ipyml
@@ -4,14 +4,6 @@ cells:
# Presenting LArray objects (Axis, Groups, Array, Session)
-- code: |
- # run this cell to avoid annoying warnings
- import warnings
- warnings.filterwarnings("ignore", message=r'.*numpy.dtype size changed*')
-
- metadata:
- nbsphinx: hidden
-
- markdown: |
Import the LArray library:
@@ -20,15 +12,6 @@ cells:
from larray import *
-- markdown: |
- Check the version of LArray:
-
-
-- code: |
- from larray import __version__
- __version__
-
-
- markdown: |
## Axis
diff --git a/doc/source/tutorial/tutorial_presenting_larray_objects.ipynb b/doc/source/tutorial/tutorial_presenting_larray_objects.ipynb
index 3bad4acb4..60cface52 100644
--- a/doc/source/tutorial/tutorial_presenting_larray_objects.ipynb
+++ b/doc/source/tutorial/tutorial_presenting_larray_objects.ipynb
@@ -7,19 +7,6 @@
"# Presenting LArray objects (Axis, Groups, Array, Session)\n"
]
},
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {
- "nbsphinx": "hidden"
- },
- "outputs": [],
- "source": [
- "# run this cell to avoid annoying warnings\n",
- "import warnings\n",
- "warnings.filterwarnings(\"ignore\", message=r'.*numpy.dtype size changed*')"
- ]
- },
{
"cell_type": "markdown",
"metadata": {},
@@ -36,23 +23,6 @@
"from larray import *"
]
},
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "Check the version of LArray:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "from larray import __version__\n",
- "__version__"
- ]
- },
{
"cell_type": "markdown",
"metadata": {},
diff --git a/doc/source/tutorial/tutorial_sessions.ipyml b/doc/source/tutorial/tutorial_sessions.ipyml
index 3865f95d4..701a4b5ed 100644
--- a/doc/source/tutorial/tutorial_sessions.ipyml
+++ b/doc/source/tutorial/tutorial_sessions.ipyml
@@ -4,14 +4,6 @@ cells:
## Working With Sessions
-- code: |
- # run this cell to avoid annoying warnings
- import warnings
- warnings.filterwarnings("ignore", message=r'.*numpy.dtype size changed*')
-
- metadata:
- nbsphinx: hidden
-
- markdown: |
Import the LArray library:
@@ -20,15 +12,6 @@ cells:
from larray import *
-- markdown: |
- Check the version of LArray:
-
-
-- code: |
- from larray import __version__
- __version__
-
-
- markdown: |
### Before To Continue
diff --git a/doc/source/tutorial/tutorial_sessions.ipynb b/doc/source/tutorial/tutorial_sessions.ipynb
index f7fbdcf16..debab3907 100644
--- a/doc/source/tutorial/tutorial_sessions.ipynb
+++ b/doc/source/tutorial/tutorial_sessions.ipynb
@@ -7,19 +7,6 @@
"## Working With Sessions\n"
]
},
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {
- "nbsphinx": "hidden"
- },
- "outputs": [],
- "source": [
- "# run this cell to avoid annoying warnings\n",
- "import warnings\n",
- "warnings.filterwarnings(\"ignore\", message=r'.*numpy.dtype size changed*')"
- ]
- },
{
"cell_type": "markdown",
"metadata": {},
@@ -36,23 +23,6 @@
"from larray import *"
]
},
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "Check the version of LArray:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "from larray import __version__\n",
- "__version__"
- ]
- },
{
"cell_type": "markdown",
"metadata": {},
diff --git a/doc/source/tutorial/tutorial_string_syntax.ipyml b/doc/source/tutorial/tutorial_string_syntax.ipyml
index 617d3b98b..bd7916a0f 100644
--- a/doc/source/tutorial/tutorial_string_syntax.ipyml
+++ b/doc/source/tutorial/tutorial_string_syntax.ipyml
@@ -12,15 +12,6 @@ cells:
from larray import *
-- markdown: |
- Check the version of LArray:
-
-
-- code: |
- from larray import __version__
- __version__
-
-
- markdown: |
The LArray library offers two syntaxes to build axes and make selections and aggregations.
The first one is more ``Pythonic`` (uses Python structures)
diff --git a/doc/source/tutorial/tutorial_string_syntax.ipynb b/doc/source/tutorial/tutorial_string_syntax.ipynb
index 9925ed3fd..484dc5f5f 100644
--- a/doc/source/tutorial/tutorial_string_syntax.ipynb
+++ b/doc/source/tutorial/tutorial_string_syntax.ipynb
@@ -23,23 +23,6 @@
"from larray import *"
]
},
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "Check the version of LArray:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "from larray import __version__\n",
- "__version__"
- ]
- },
{
"cell_type": "markdown",
"metadata": {},
diff --git a/doc/source/tutorial/tutorial_transforming.ipyml b/doc/source/tutorial/tutorial_transforming.ipyml
index 8b3f438ae..3e5ecae8d 100644
--- a/doc/source/tutorial/tutorial_transforming.ipyml
+++ b/doc/source/tutorial/tutorial_transforming.ipyml
@@ -4,14 +4,6 @@ cells:
# Transforming Arrays (Relabeling, Renaming, Reordering, Combining, Extending, Sorting, ...)
-- code: |
- # run this cell to avoid annoying warnings
- import warnings
- warnings.filterwarnings("ignore", message=r'.*numpy.dtype size changed*')
-
- metadata:
- nbsphinx: hidden
-
- markdown: |
Import the LArray library:
@@ -20,15 +12,6 @@ cells:
from larray import *
-- markdown: |
- Check the version of LArray:
-
-
-- code: |
- from larray import __version__
- __version__
-
-
- code: |
# load the 'demography_eurostat' dataset
demo_eurostat = load_example_data('demography_eurostat')
diff --git a/doc/source/tutorial/tutorial_transforming.ipynb b/doc/source/tutorial/tutorial_transforming.ipynb
index 7fc6505ab..4a6947612 100644
--- a/doc/source/tutorial/tutorial_transforming.ipynb
+++ b/doc/source/tutorial/tutorial_transforming.ipynb
@@ -7,19 +7,6 @@
"# Transforming Arrays (Relabeling, Renaming, Reordering, Combining, Extending, Sorting, ...)\n"
]
},
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {
- "nbsphinx": "hidden"
- },
- "outputs": [],
- "source": [
- "# run this cell to avoid annoying warnings\n",
- "import warnings\n",
- "warnings.filterwarnings(\"ignore\", message=r'.*numpy.dtype size changed*')"
- ]
- },
{
"cell_type": "markdown",
"metadata": {},
@@ -36,23 +23,6 @@
"from larray import *"
]
},
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "Check the version of LArray:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "from larray import __version__\n",
- "__version__"
- ]
- },
{
"cell_type": "code",
"execution_count": null,