Skip to content

BUG: nth on series groupby with dropna=True gives TypeError #7628

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jorisvandenbossche opened this issue Jul 1, 2014 · 1 comment · Fixed by #7631
Closed

BUG: nth on series groupby with dropna=True gives TypeError #7628

jorisvandenbossche opened this issue Jul 1, 2014 · 1 comment · Fixed by #7631

Comments

@jorisvandenbossche
Copy link
Member

From the docs: http://pandas-docs.github.io/pandas-docs-travis/groupby.html#taking-the-nth-row-of-each-group

In [1]: df = DataFrame([[1, np.nan], [1, 4], [5, 6]], columns=['A', 'B'])

In [2]: g = df.groupby('A')

In [3]: g.B.nth(0, dropna=True)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-3-bcb9dcbefdf5> in <module>()
----> 1 g.B.nth(0, dropna=True)

C:\Users\vdbosscj\Scipy\pandas-joris\pandas\core\groupby.py in nth(self, n, drop
na)
    831         # get a new grouper for our dropped obj
    832         grouper, exclusions, obj = _get_grouper(dropped, key=self.keys,
axis=self.axis,
--> 833                                                 level=self.level, sort=s
elf.sort)
    834
    835         sizes = obj.groupby(grouper).size()

C:\Users\vdbosscj\Scipy\pandas-joris\pandas\core\groupby.py in _get_grouper(obj,
 key, axis, level, sort)
   2035             raise AssertionError(errmsg)
   2036
-> 2037         ping = Grouping(group_axis, gpr, obj=obj, name=name, level=level
, sort=sort)
   2038         groupings.append(ping)
   2039

C:\Users\vdbosscj\Scipy\pandas-joris\pandas\core\groupby.py in __init__(self, in
dex, grouper, obj, name, level, sort)
   1874             # no level passed
   1875             if not isinstance(self.grouper, (Series, np.ndarray)):
-> 1876                 self.grouper = self.index.map(self.grouper)
   1877                 if not (hasattr(self.grouper, "__len__") and
   1878                         len(self.grouper) == len(self.index)):

C:\Users\vdbosscj\Scipy\pandas-joris\pandas\core\index.py in map(self, mapper)
   1332
   1333     def map(self, mapper):
-> 1334         return self._arrmap(self.values, mapper)
   1335
   1336     def isin(self, values):

C:\Users\vdbosscj\Scipy\pandas-joris\pandas\algos.pyd in pandas.algos.arrmap_int
64 (pandas\algos.c:72351)()

TypeError: 'NoneType' object is not callable
@jorisvandenbossche jorisvandenbossche added this to the 0.14.1 milestone Jul 1, 2014
@jreback
Copy link
Contributor

jreback commented Jul 1, 2014

related #7580

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants