Skip to content

Commit

Permalink
example
Browse files Browse the repository at this point in the history
  • Loading branch information
loco-philippe committed May 26, 2024
1 parent 43da5f2 commit 1a4cb1d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 19 deletions.
6 changes: 4 additions & 2 deletions example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

## Multidimensional examples

The [first example](https://nbviewer.org/github/loco-philippe/ntv-pandas/blob/main/example/example_multidimensional.ipynb) presents the multidimensional interfaces.
The [first notebook](https://nbviewer.org/github/loco-philippe/ntv-pandas/blob/main/example/example_multidimensional.ipynb) presents the multidimensional interfaces.

A [second example](https://nbviewer.org/github/loco-philippe/ntv-pandas/blob/main/example/xarray_pandas_converter.ipynb) presents the Xarray interface.
A [second notebook](https://nbviewer.org/github/loco-philippe/ntv-pandas/blob/main/example/xarray_pandas_converter.ipynb) show how the ntv_pandas converter complements the existing Xarray interface.

A [simple use case](https://nbviewer.org/github/loco-philippe/ntv-pandas/blob/main/example/example_xarray.ipynb) shows the advantage of multidimensional representation (conversion Xarray of a dataset, optimization of data size).

## DataFrame integrity

Expand Down
33 changes: 18 additions & 15 deletions example/example_xarray.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,31 @@
"\n",
"It shows that :\n",
"- data can simply be represented in multidimensional format and used in Xarray\n",
"- the multidimensional JSON format is the most compact of the usual formats (tabular JSON, csv and even parquet),"
"- the multidimensional JSON format is the most compact of the usual formats (tabular JSON, CSV and even Parquet)."
]
},
{
"cell_type": "markdown",
"id": "d4d247a5-0273-4026-ae99-ead4cd957f38",
"metadata": {},
"metadata": {
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"## description of the example\n",
"## use case description\n",
"\n",
"Sensors are installed in five french cities (lille, toulouse, marseille, strasbourg, brest) and measure air quality during ten days.\n",
"The measurement is the hourly mean of pollutants concentration (PM10, PM2.5, NO2, O3, CO).\n",
"Sensors are installed in five French cities (lille, toulouse, marseille, strasbourg, brest) and measure air quality for ten days.\n",
"The measurement is the hourly average of pollutant concentrations (PM10, PM2.5, NO2, O3, CO).\n",
"\n",
"The result of the acquisition is a table where fields are:\n",
"The result of the acquisition is a table where the fields are:\n",
"\n",
"- camp : description of the campaign\n",
"- date : date of the measurement\n",
"- hour : hour of the measurement\n",
"- city : location of the sensor\n",
"- coord : coordinate of the sensor\n",
"- date : date of measurement\n",
"- hour : hour of measurement\n",
"- city : sensor location\n",
"- coord : sensor coordinate\n",
"- prop : measured property\n",
"- unit : unit of the measurement\n",
"- value : value of the measurement"
"- unit : unit of measurement\n",
"- value : value of measurement"
]
},
{
Expand Down Expand Up @@ -294,7 +296,9 @@
"id": "3c4ff8af-ff61-44a5-8665-7110a770eaf1",
"metadata": {},
"source": [
"## Multidimensional representation"
"## Multidimensional representation\n",
"\n",
"The DataFrame is simply converted to an Xarray."
]
},
{
Expand Down Expand Up @@ -797,7 +801,7 @@
"source": [
"## data size\n",
"\n",
"The multidimensional JSON size is lower than tabular JSON size, csv size and parquet size"
"The multidimensional JSON size is smaller than the tabular JSON size, csv size and parquet size"
]
},
{
Expand Down Expand Up @@ -840,7 +844,6 @@
" 'pd.to_csv': len(meas_df_1.to_csv()),\n",
" 'pd.to_parquet': os.path.getsize('meas_1.parquet'),\n",
" 'nxr.to_json': len(meas_js_1)}\n",
"\n",
"size_1"
]
},
Expand Down
6 changes: 4 additions & 2 deletions example/xarray_pandas_converter.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
"# Xarray - Pandas converter\n",
"---------------------------\n",
"\n",
"This example is the example used in Xarray user-guide (section [\"working with pandas\"](https://docs.xarray.dev/en/stable/user-guide/pandas.html)).\n",
"This Notebook uses the example used in Xarray user-guide (section [\"working with pandas\"](https://docs.xarray.dev/en/stable/user-guide/pandas.html)) to show how the ntv_pandas converter complements the existing Xarray interface.\n",
"\n",
"A more complete example is in the [other Notebook](https://nbviewer.org/github/loco-philippe/ntv-pandas/blob/main/example/example_multidimensional.ipynb)."
"A [simple use case](https://nbviewer.org/github/loco-philippe/ntv-pandas/blob/main/example/example_multidimensional.ipynb) shows the advantage of multidimensional representation (conversion Xarray of a dataset, optimization of data size).\n",
"\n",
"A [third example](https://nbviewer.org/github/loco-philippe/ntv-pandas/blob/main/example/example_multidimensional.ipynb) shows how the hidden multidimensional structure of a tabular dataset can be revealed."
]
},
{
Expand Down

0 comments on commit 1a4cb1d

Please sign in to comment.