question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

False positive for "nested renamer is not supported" error

See original GitHub issue

Code Sample

import pandas as pd

df = pd.DataFrame({'A': [1, 1, 1, 2, 2],  'B': range(5), 'C': range(5)})
df.groupby('A').agg({'B': 'sum', 'G': 'min'})  # aggregate by a non existing column

produces

<ipython-input-5-f5ac34bf856f> in <module>
----> 1 df.groupby('A').agg({'B': 'sum', 'G': 'min'})

~/src/dgr00/.venv3/lib/python3.6/site-packages/pandas/core/groupby/generic.py in aggregate(self, func, *args, **kwargs)
    938         func = _maybe_mangle_lambdas(func)
    939
--> 940         result, how = self._aggregate(func, *args, **kwargs)
    941         if how is None:
    942             return result

~/src/dgr00/.venv3/lib/python3.6/site-packages/pandas/core/base.py in _aggregate(self, arg, *args, **kwargs)
    364                     obj.columns.intersection(keys)
    365                 ) != len(keys):
--> 366                     raise SpecificationError("nested renamer is not supported")
    367
    368             from pandas.core.reshape.concat import concat

SpecificationError: nested renamer is not supported

Problem description

While groupby.agg() with a dictionary when renaming was deprecated in 1.0 ( https://pandas.pydata.org/pandas-docs/stable/whatsnew/v0.20.0.html#deprecate-groupby-agg-with-a-dictionary-when-renaming) the corresponding error message can also be obtained when aggregating by an non existing column which can lead to confusion.

Expected Output

Error saying that the column G does not exist.

Output of pd.show_versions()

INSTALLED VERSIONS

python : 3.6.4.final.0 OS : Linux machine : x86_64 pandas : 1.0.1

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:15
  • Comments:16 (4 by maintainers)

github_iconTop GitHub Comments

15reactions
janithahncommented, Jun 21, 2020

Instead of using .agg({'B': 'sum', 'G': 'min'}), try passing it as a list of tuples like .agg([('B', 'sum'), ('G', 'min')]).

5reactions
tanglade22commented, Mar 12, 2020

Same problem here, bug is due to non-existing column

Read more comments on GitHub >

github_iconTop Results From Across the Web

nested renamer is not supported while agg() along with ...
python - Solution for SpecificationError: nested renamer is not supported while agg() along with groupby() - Stack Overflow. Stack Overflow for ...
Read more >
SpecificationError: nested renamer is not supported
I hope you get the above problem in the stack plot, right. It is just because of the update in pandas.
Read more >
SpecificationError: nested renamer is not supported - CSDN博客
False positive for “nested renamer is not supported” error #32156. 原文链接: https://blog.csdn.net/icelights/article/details/108047815.
Read more >
Visual Studio 2019 version 16.11 Release Notes
Get the latest features, bug fixes, and support for Visual Studio 2019 v16.11. Download today.
Read more >
Changelog and Migration Guide - Detekt
ArrayPrimitive is now working only with Type Resolution - #5175 ... AlsoCouldBeApply: fix false positive when all statements are not it -started expressions ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found