From 14857c65582bdba10b2e6fa3b8021d863c8d0e1c Mon Sep 17 00:00:00 2001 From: MomIsBestFriend <> Date: Wed, 6 Nov 2019 23:47:20 +0200 Subject: [PATCH 1/4] Improving (hopfully) the docs --- pandas/_libs/algos.pyx | 24 +++++++++++++++++------- pandas/core/accessor.py | 10 +++++----- requirements-dev.txt | 2 +- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/pandas/_libs/algos.pyx b/pandas/_libs/algos.pyx index 2d6c8e1008ce1..d3fa5de0f0d02 100644 --- a/pandas/_libs/algos.pyx +++ b/pandas/_libs/algos.pyx @@ -84,8 +84,8 @@ cpdef ndarray[int64_t, ndim=1] unique_deltas(const int64_t[:] arr): Returns ------- - result : ndarray[int64_t] - result is sorted + ndarray[int64_t] + An ordered ndarray[int64_t] """ cdef: Py_ssize_t i, n = len(arr) @@ -150,9 +150,10 @@ def is_lexsorted(list_of_arrays: list) -> bint: @cython.wraparound(False) def groupsort_indexer(const int64_t[:] index, Py_ssize_t ngroups): """ - compute a 1-d indexer that is an ordering of the passed index, - ordered by the groups. This is a reverse of the label - factorization process. + Compute a 1-d indexer. + + The indexer is an ordering of the passed index, + ordered by the groups. Parameters ---------- @@ -161,7 +162,14 @@ def groupsort_indexer(const int64_t[:] index, Py_ssize_t ngroups): ngroups: int64 number of groups - return a tuple of (1-d indexer ordered by groups, group counts) + Returns + ------- + tuple + 1-d indexer ordered by groups, group counts + + Notes + ----- + This is a reverse of the label factorization process. """ cdef: @@ -391,6 +399,7 @@ def _validate_limit(nobs: int, limit=None) -> int: Returns ------- int + The limit. """ if limit is None: lim = nobs @@ -669,7 +678,8 @@ def is_monotonic(ndarray[algos_t, ndim=1] arr, bint timelike): """ Returns ------- - is_monotonic_inc, is_monotonic_dec, is_unique + tuple + is_monotonic_inc, is_monotonic_dec, is_unique """ cdef: Py_ssize_t i, n diff --git a/pandas/core/accessor.py b/pandas/core/accessor.py index fc60c01d7b808..2d1986ab272d1 100644 --- a/pandas/core/accessor.py +++ b/pandas/core/accessor.py @@ -197,7 +197,7 @@ def decorator(accessor): _doc = """ -Register a custom accessor on %(klass)s objects. +Register a custom accessor on {klass} objects. Parameters ---------- @@ -212,7 +212,7 @@ def decorator(accessor): See Also -------- -%(others)s +{others} Notes ----- @@ -268,7 +268,7 @@ def plot(self): @Appender( _doc - % dict( + .format( klass="DataFrame", others=("register_series_accessor, register_index_accessor") ) ) @@ -280,7 +280,7 @@ def register_dataframe_accessor(name): @Appender( _doc - % dict( + .format( klass="Series", others=("register_dataframe_accessor, register_index_accessor") ) ) @@ -292,7 +292,7 @@ def register_series_accessor(name): @Appender( _doc - % dict( + .format( klass="Index", others=("register_dataframe_accessor, register_series_accessor") ) ) diff --git a/requirements-dev.txt b/requirements-dev.txt index e7df704925485..b6f6f6dd4b2b6 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -65,4 +65,4 @@ xlsxwriter xlwt odfpy pyreadstat -git+https://github.com/pandas-dev/pandas-sphinx-theme.git@master \ No newline at end of file +git+https://github.com/pandas-dev/pandas-sphinx-theme.git@master From d0e42248ba274778d6bbf5378420c4df351c95ef Mon Sep 17 00:00:00 2001 From: MomIsBestFriend <> Date: Wed, 6 Nov 2019 23:59:09 +0200 Subject: [PATCH 2/4] Improved (hopefully) the documantion --- pandas/_libs/algos.pyx | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/pandas/_libs/algos.pyx b/pandas/_libs/algos.pyx index 2d6c8e1008ce1..d3fa5de0f0d02 100644 --- a/pandas/_libs/algos.pyx +++ b/pandas/_libs/algos.pyx @@ -84,8 +84,8 @@ cpdef ndarray[int64_t, ndim=1] unique_deltas(const int64_t[:] arr): Returns ------- - result : ndarray[int64_t] - result is sorted + ndarray[int64_t] + An ordered ndarray[int64_t] """ cdef: Py_ssize_t i, n = len(arr) @@ -150,9 +150,10 @@ def is_lexsorted(list_of_arrays: list) -> bint: @cython.wraparound(False) def groupsort_indexer(const int64_t[:] index, Py_ssize_t ngroups): """ - compute a 1-d indexer that is an ordering of the passed index, - ordered by the groups. This is a reverse of the label - factorization process. + Compute a 1-d indexer. + + The indexer is an ordering of the passed index, + ordered by the groups. Parameters ---------- @@ -161,7 +162,14 @@ def groupsort_indexer(const int64_t[:] index, Py_ssize_t ngroups): ngroups: int64 number of groups - return a tuple of (1-d indexer ordered by groups, group counts) + Returns + ------- + tuple + 1-d indexer ordered by groups, group counts + + Notes + ----- + This is a reverse of the label factorization process. """ cdef: @@ -391,6 +399,7 @@ def _validate_limit(nobs: int, limit=None) -> int: Returns ------- int + The limit. """ if limit is None: lim = nobs @@ -669,7 +678,8 @@ def is_monotonic(ndarray[algos_t, ndim=1] arr, bint timelike): """ Returns ------- - is_monotonic_inc, is_monotonic_dec, is_unique + tuple + is_monotonic_inc, is_monotonic_dec, is_unique """ cdef: Py_ssize_t i, n From 348861cffa39710f3319c630a19f3f19b37f3492 Mon Sep 17 00:00:00 2001 From: MomIsBestFriend <> Date: Thu, 7 Nov 2019 00:11:26 +0200 Subject: [PATCH 3/4] Improved docs --- pandas/core/accessor.py | 10 +++++----- requirements-dev.txt | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pandas/core/accessor.py b/pandas/core/accessor.py index 2d1986ab272d1..fc60c01d7b808 100644 --- a/pandas/core/accessor.py +++ b/pandas/core/accessor.py @@ -197,7 +197,7 @@ def decorator(accessor): _doc = """ -Register a custom accessor on {klass} objects. +Register a custom accessor on %(klass)s objects. Parameters ---------- @@ -212,7 +212,7 @@ def decorator(accessor): See Also -------- -{others} +%(others)s Notes ----- @@ -268,7 +268,7 @@ def plot(self): @Appender( _doc - .format( + % dict( klass="DataFrame", others=("register_series_accessor, register_index_accessor") ) ) @@ -280,7 +280,7 @@ def register_dataframe_accessor(name): @Appender( _doc - .format( + % dict( klass="Series", others=("register_dataframe_accessor, register_index_accessor") ) ) @@ -292,7 +292,7 @@ def register_series_accessor(name): @Appender( _doc - .format( + % dict( klass="Index", others=("register_dataframe_accessor, register_series_accessor") ) ) diff --git a/requirements-dev.txt b/requirements-dev.txt index b6f6f6dd4b2b6..e7df704925485 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -65,4 +65,4 @@ xlsxwriter xlwt odfpy pyreadstat -git+https://github.com/pandas-dev/pandas-sphinx-theme.git@master +git+https://github.com/pandas-dev/pandas-sphinx-theme.git@master \ No newline at end of file From 2cbb95eaf70e7b8ad83512c6a9f5e7614a7e2ecf Mon Sep 17 00:00:00 2001 From: MomIsBestFriend <50263213+MomIsBestFriend@users.noreply.github.com> Date: Thu, 7 Nov 2019 00:43:05 +0200 Subject: [PATCH 4/4] Update algos.pyx --- pandas/_libs/algos.pyx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/_libs/algos.pyx b/pandas/_libs/algos.pyx index d3fa5de0f0d02..c2d6a3bc4906d 100644 --- a/pandas/_libs/algos.pyx +++ b/pandas/_libs/algos.pyx @@ -164,8 +164,8 @@ def groupsort_indexer(const int64_t[:] index, Py_ssize_t ngroups): Returns ------- - tuple - 1-d indexer ordered by groups, group counts + tuple + 1-d indexer ordered by groups, group counts Notes -----