From 8fb09a538091efe1924c7ac9d22172ad2c873715 Mon Sep 17 00:00:00 2001 From: MomIsBestFriend <> Date: Wed, 18 Mar 2020 01:47:04 +0200 Subject: [PATCH 1/3] BLD: Suppressing errors while compling pandas/_libs/groupby --- pandas/_libs/groupby.pyx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/pandas/_libs/groupby.pyx b/pandas/_libs/groupby.pyx index 35a6963165194..564e0152b28f8 100644 --- a/pandas/_libs/groupby.pyx +++ b/pandas/_libs/groupby.pyx @@ -869,7 +869,9 @@ def group_last(rank_t[:, :] out, assert min_count == -1, "'min_count' only used in add and prod" - if not len(values) == len(labels): + # NOTE: + # Casting to avoid build warnings + if not len(values) == len(labels): raise AssertionError("len(index) != len(labels)") nobs = np.zeros((out).shape, dtype=np.int64) @@ -960,7 +962,9 @@ def group_nth(rank_t[:, :] out, assert min_count == -1, "'min_count' only used in add and prod" - if not len(values) == len(labels): + # NOTE: + # Casting to avoid build warnings + if not len(values) == len(labels): raise AssertionError("len(index) != len(labels)") nobs = np.zeros((out).shape, dtype=np.int64) @@ -1254,7 +1258,9 @@ def group_max(groupby_t[:, :] out, assert min_count == -1, "'min_count' only used in add and prod" - if not len(values) == len(labels): + # NOTE: + # Casting to avoid build warnings + if not len(values) == len(labels): raise AssertionError("len(index) != len(labels)") nobs = np.zeros((out).shape, dtype=np.int64) @@ -1327,7 +1333,9 @@ def group_min(groupby_t[:, :] out, assert min_count == -1, "'min_count' only used in add and prod" - if not len(values) == len(labels): + # NOTE: + # Casting to avoid build warnings + if not len(values) == len(labels): raise AssertionError("len(index) != len(labels)") nobs = np.zeros((out).shape, dtype=np.int64) From 289e4336772ecc2ebf5d7a1be51965d625ce984d Mon Sep 17 00:00:00 2001 From: MomIsBestFriend <> Date: Wed, 18 Mar 2020 02:05:32 +0200 Subject: [PATCH 2/3] Using labels.shape[0] instead of casting REF: https://github.com/pandas-dev/pandas/pull/32794#discussion_r394037406 --- pandas/_libs/groupby.pyx | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/pandas/_libs/groupby.pyx b/pandas/_libs/groupby.pyx index 564e0152b28f8..fd946c680ae0b 100644 --- a/pandas/_libs/groupby.pyx +++ b/pandas/_libs/groupby.pyx @@ -869,9 +869,7 @@ def group_last(rank_t[:, :] out, assert min_count == -1, "'min_count' only used in add and prod" - # NOTE: - # Casting to avoid build warnings - if not len(values) == len(labels): + if not len(values) == labels.shape[0]: raise AssertionError("len(index) != len(labels)") nobs = np.zeros((out).shape, dtype=np.int64) @@ -962,9 +960,7 @@ def group_nth(rank_t[:, :] out, assert min_count == -1, "'min_count' only used in add and prod" - # NOTE: - # Casting to avoid build warnings - if not len(values) == len(labels): + if not len(values) == labels.shape[0]: raise AssertionError("len(index) != len(labels)") nobs = np.zeros((out).shape, dtype=np.int64) @@ -1258,9 +1254,7 @@ def group_max(groupby_t[:, :] out, assert min_count == -1, "'min_count' only used in add and prod" - # NOTE: - # Casting to avoid build warnings - if not len(values) == len(labels): + if not len(values) == labels.shape[0]: raise AssertionError("len(index) != len(labels)") nobs = np.zeros((out).shape, dtype=np.int64) @@ -1333,9 +1327,7 @@ def group_min(groupby_t[:, :] out, assert min_count == -1, "'min_count' only used in add and prod" - # NOTE: - # Casting to avoid build warnings - if not len(values) == len(labels): + if not len(values) == labels.shape[0]: raise AssertionError("len(index) != len(labels)") nobs = np.zeros((out).shape, dtype=np.int64) From ea678f0985be7112789b0d0ba6b5fbdde4274de6 Mon Sep 17 00:00:00 2001 From: MomIsBestFriend <> Date: Wed, 18 Mar 2020 11:52:29 +0200 Subject: [PATCH 3/3] Added "TODO" comments --- pandas/_libs/groupby.pyx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pandas/_libs/groupby.pyx b/pandas/_libs/groupby.pyx index fd946c680ae0b..e7ac3b8442c6d 100644 --- a/pandas/_libs/groupby.pyx +++ b/pandas/_libs/groupby.pyx @@ -869,6 +869,8 @@ def group_last(rank_t[:, :] out, assert min_count == -1, "'min_count' only used in add and prod" + # TODO(cython 3.0): + # Instead of `labels.shape[0]` use `len(labels)` if not len(values) == labels.shape[0]: raise AssertionError("len(index) != len(labels)") @@ -960,6 +962,8 @@ def group_nth(rank_t[:, :] out, assert min_count == -1, "'min_count' only used in add and prod" + # TODO(cython 3.0): + # Instead of `labels.shape[0]` use `len(labels)` if not len(values) == labels.shape[0]: raise AssertionError("len(index) != len(labels)") @@ -1254,6 +1258,8 @@ def group_max(groupby_t[:, :] out, assert min_count == -1, "'min_count' only used in add and prod" + # TODO(cython 3.0): + # Instead of `labels.shape[0]` use `len(labels)` if not len(values) == labels.shape[0]: raise AssertionError("len(index) != len(labels)") @@ -1327,6 +1333,8 @@ def group_min(groupby_t[:, :] out, assert min_count == -1, "'min_count' only used in add and prod" + # TODO(cython 3.0): + # Instead of `labels.shape[0]` use `len(labels)` if not len(values) == labels.shape[0]: raise AssertionError("len(index) != len(labels)")