False positive for "nested renamer is not supported" error
See original GitHub issueCode 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:
- Created 4 years ago
- Reactions:15
- Comments:16 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Instead of using
.agg({'B': 'sum', 'G': 'min'})
, try passing it as a list of tuples like.agg([('B', 'sum'), ('G', 'min')])
.Same problem here, bug is due to non-existing column