You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/ecosystem.rst
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -74,6 +74,7 @@ Extend xarray capabilities
74
74
- `Collocate <https://github.com/cistools/collocate>`_: Collocate xarray trajectories in arbitrary physical dimensions
75
75
- `eofs <https://ajdawson.github.io/eofs/>`_: EOF analysis in Python.
76
76
- `hypothesis-gufunc <https://hypothesis-gufunc.readthedocs.io/en/latest/>`_: Extension to hypothesis. Makes it easy to write unit tests with xarray objects as input.
77
+
- `ntv-pandas <https://github.com/loco-philippe/ntv-pandas>`_ : A tabular analyzer and a semantic, compact and reversible converter for multidimensional and tabular data
77
78
- `nxarray <https://github.com/nxarray/nxarray>`_: NeXus input/output capability for xarray.
78
79
- `xarray-compare <https://github.com/astropenguin/xarray-compare>`_: xarray extension for data comparison.
79
80
- `xarray-dataclasses <https://github.com/astropenguin/xarray-dataclasses>`_: xarray extension for typed DataArray and Dataset creation.
Copy file name to clipboardExpand all lines: doc/user-guide/pandas.rst
+20Lines changed: 20 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -110,6 +110,26 @@ work even if not the hierarchical index is not a full tensor product:
110
110
s[::2]
111
111
s[::2].to_xarray()
112
112
113
+
Lossless and reversible conversion
114
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
115
+
116
+
The previous ``Dataset`` example shows that the conversion is not reversible (lossy roundtrip) and
117
+
that the size of the ``Dataset`` increases.
118
+
119
+
Particularly after a roundtrip, the following deviations are noted:
120
+
121
+
- a non-dimension Dataset ``coordinate`` is converted into ``variable``
122
+
- a non-dimension DataArray ``coordinate`` is not converted
123
+
- ``dtype`` is not allways the same (e.g. "str" is converted to "object")
124
+
- ``attrs`` metadata is not conserved
125
+
126
+
To avoid these problems, the third-party `ntv-pandas <https://github.com/loco-philippe/ntv-pandas>`__ library offers lossless and reversible conversions between
127
+
``Dataset``/ ``DataArray`` and pandas ``DataFrame`` objects.
128
+
129
+
This solution is particularly interesting for converting any ``DataFrame`` into a ``Dataset`` (the converter find the multidimensional structure hidden by the tabular structure).
130
+
131
+
The `ntv-pandas examples <https://github.com/loco-philippe/ntv-pandas/tree/main/example>`__ show how to improve the conversion for the previous ``Dataset`` example and for more complex examples.
0 commit comments