From 90c16fe30645aa9f8f4b30f35ca934dcb88e4e73 Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 30 Dec 2024 00:58:18 +0000 Subject: [PATCH] docs --- docs/getting/tutorial.rst | 2 +- docs/user/initializing.rst | 17 +++++++++++++++++ docs/user/numpy.rst | 4 ++-- requirements_docs.txt | 1 + 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/docs/getting/tutorial.rst b/docs/getting/tutorial.rst index f28e5e5..ae7cf6c 100644 --- a/docs/getting/tutorial.rst +++ b/docs/getting/tutorial.rst @@ -49,7 +49,7 @@ Operations with columns are units aware so behave as we would intuitively expect Notice that the units are not displayed in the cells of the DataFrame. If you ever see units in the cells of the DataFrame, something isn't right. - See :ref:`units_in_cells` for more information. + See :doc:`Units in Cells <../user/common>` for more information. We can see the columns' units in the dtypes attribute diff --git a/docs/user/initializing.rst b/docs/user/initializing.rst index 2dce321..291b115 100644 --- a/docs/user/initializing.rst +++ b/docs/user/initializing.rst @@ -54,3 +54,20 @@ To avoid this conversion, specify the subdtype (dtype of the magnitudes) in the .. note:: ``"pint[unit]"`` or ``"pint[unit][subdtype]"`` must be used for the Series or DataFrame constuctor. + +Non-native pandas dtypes +------------------------- + +``PintArray`` uses an ``ExtensionArray`` to hold its data inclluding those from other libraries that extend pandas. +For example, an ``UncertaintyArray`` can be used. + +.. ipython:: python + + from uncertainties_pandas import UncertaintyArray, UncertaintyDtype + from uncertainties import ufloat, umath, unumpy + + ufloats = [ufloat(i, abs(i) / 100) for i in [4.0, np.nan, -5.0]] + uarr = UncertaintyArray(ufloats) + uarr + PintArray(uarr,"m") + pd.Series(PintArray(uarr,"m")*2) diff --git a/docs/user/numpy.rst b/docs/user/numpy.rst index eb9390b..91a90f7 100644 --- a/docs/user/numpy.rst +++ b/docs/user/numpy.rst @@ -17,10 +17,10 @@ Numpy functions that work on pint ``Quantity`` ``ndarray`` objects also work on PintArray = pint_pandas.PintArray ureg = pint_pandas.PintType.ureg - Q_ = ureg.Quantity + Quantity = ureg.Quantity .. ipython:: python - + pa = PintArray([1, 2, np.nan, 4, 10], dtype="pint[m]") np.clip(pa, 3 * ureg.m, 5 * ureg.m) diff --git a/requirements_docs.txt b/requirements_docs.txt index c8ae06e..93be184 100644 --- a/requirements_docs.txt +++ b/requirements_docs.txt @@ -20,3 +20,4 @@ sphinx-book-theme>=1.1.0 sphinx_copybutton sphinx_design typing_extensions +uncertainties-pandas