From 2207db3fad1428f65771899c5bc03b3d45c6b420 Mon Sep 17 00:00:00 2001 From: Bert Palm <bert.palm@ufz.de> Date: Tue, 21 Apr 2020 14:22:48 +0200 Subject: [PATCH] save --- dios/base.py | 70 +++++++++++++++++++ dox/{_diosApi.rst => dios_api.rst} | 0 dox/{cookbook.md => doc_cookbook.md} | 0 dox/{indexingDocs.md => doc_indexing.md} | 0 dox/doc_itype.md | 2 + ...md => doc_methods_and_properties.markdown} | 0 dox/index.rst | 14 ++-- 7 files changed, 81 insertions(+), 5 deletions(-) rename dox/{_diosApi.rst => dios_api.rst} (100%) rename dox/{cookbook.md => doc_cookbook.md} (100%) rename dox/{indexingDocs.md => doc_indexing.md} (100%) create mode 100644 dox/doc_itype.md rename dox/{methods_and_properties.md => doc_methods_and_properties.markdown} (100%) diff --git a/dios/base.py b/dios/base.py index 48a5300..44fa64c 100644 --- a/dios/base.py +++ b/dios/base.py @@ -318,6 +318,7 @@ class _DiosBase: @property def columns(self): + """ The column labels of the DictOfSeries """ return self._data.index @columns.setter @@ -329,6 +330,10 @@ class _DiosBase: @property def itype(self): + """ The ``Itype`` of the DictOfSeries. + + See :ref:`Itype documentation <doc_itype:Itype>` for more info. + """ if self._itype == 'INFER': return None return self._itype @@ -341,6 +346,10 @@ class _DiosBase: @property def cast_policy(self): + """ The policy to use for casting new columns if its initial itype does not fit. + + See :ref:`Itype documentation <doc_itype:Itype>` for more info. + """ return self._policy @cast_policy.setter @@ -363,6 +372,47 @@ class _DiosBase: @property def empty(self): + """ Indicator whether DictOfSeries is empty. + + Returns + ------- + bool : + If DictOfSeries is empty, return True, if not return False. + + See Also + -------- + DictOfSeries.dropempty : drop empty columns + DictOfSeries.dropna : drop NAN's from a DictOfSeries + pandas.Series.dropna : drop NAN's from a Series + + Notes + ----- + If DictOfSeries contains only NaNs, it is still not considered empty. See the example below. + + Examples + -------- + An example of an actual empty DictOfSeries. + + >>> di_empty = DictOfSeries(columns=['A']) + >>> di_empty + Empty DictOfSeries + Columns: ['A'] + >>> di_empty.empty + True + + If we only have NaNs in our DictOfSeries, it is not considered empty! + We will need to drop the NaNs to make the DictOfSeries empty: + + >>> di = pd.DictOfSeries({'A' : [np.nan]}) + >>> di + A | + ===== | + 0 NaN | + >>> di.empty + False + >>> di.dropna().empty + True + """ return len(self) == 0 or all(s.empty for s in self._data) def __iter__(self): @@ -384,6 +434,22 @@ class _DiosBase: return self.copy(deep=True) def copy(self, deep=True): + """ Make a copy of this DictOfSeries' indices and data. + + Parameters + ---------- + deep : bool, default True + Make a deep copy, including a copy of the data and the indices. + With deep=False neither the indices nor the data are copied. + + Returns + ------- + copy : DictOfSeries + + See Also + -------- + pandas.DataFrame.copy + """ if deep: data = pd.Series(dtype='O', index=self.columns) for c in self.columns: @@ -479,6 +545,10 @@ class _DiosBase: @property def loc(self): + """ Location Indexer. + + See :ref:`indexing docs <doc_indexing:Pandas-like indexing>` + """ return _LocIndexer(self) @property diff --git a/dox/_diosApi.rst b/dox/dios_api.rst similarity index 100% rename from dox/_diosApi.rst rename to dox/dios_api.rst diff --git a/dox/cookbook.md b/dox/doc_cookbook.md similarity index 100% rename from dox/cookbook.md rename to dox/doc_cookbook.md diff --git a/dox/indexingDocs.md b/dox/doc_indexing.md similarity index 100% rename from dox/indexingDocs.md rename to dox/doc_indexing.md diff --git a/dox/doc_itype.md b/dox/doc_itype.md new file mode 100644 index 0000000..070f205 --- /dev/null +++ b/dox/doc_itype.md @@ -0,0 +1,2 @@ +Itype +===== \ No newline at end of file diff --git a/dox/methods_and_properties.md b/dox/doc_methods_and_properties.markdown similarity index 100% rename from dox/methods_and_properties.md rename to dox/doc_methods_and_properties.markdown diff --git a/dox/index.rst b/dox/index.rst index 4145e36..1257101 100644 --- a/dox/index.rst +++ b/dox/index.rst @@ -15,22 +15,26 @@ the class :class:`dios.DictOfSeries`. See dios.DictOfSeries <_api/dios.DictOfSeries> -For some recipes and advanced usage see: +Most magic happen in getting and setting elements. +To select any combination from columns and rows, +read the documentation about indexing: .. toctree:: - indexingDocs + doc_indexing .. toctree:: - cookbook + doc_cookbook -For full module api documentation see: + +For implemented methods and module functions, +respectively the full module api, see: .. toctree:: :maxdepth: 2 - _diosApi + dios_api or browse the Index.. -- GitLab