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
BUG: groupby.agg
with as_index=False
and duplicate columns in by
fails with pd.NamedAgg
.
#58446
Comments
Thanks for the report. You checked the box
Can you confirm if you are seeing an error or the above output on main? |
I can't seem to install ModuleNotFoundError: No module named 'pandas._libs.pandas_parser' but I did notice that the bug is happening on the latest version of pandas - 2.2.2. |
@sfc-gh-rdurrani Your code runs fine without any errors in main branch for me.
Try creating an isolated environment using mamba (recommended) or pip, install the requirements in requirements-dev.txt and try installing pandas from source. More information here: https://pandas.pydata.org/docs/dev/development/contributing_environment.html |
Thanks @sfc-gh-rdurrani - there isn't a requirement to try it out on main (but you're certainly welcome to!). I just wanted to make sure I wasn't making a mistake when I see this is fixed on the main branch. |
take |
…amedAgg` and `asIndex=False` (pandas-dev#58579) * implement test for GH pandas-dev#58446 * Reformat GH issue comment * Directly inline as_index=False in groupby call --------- Co-authored-by: Jason Mok <jasonmok@Jasons-MacBook-Air-4.local>
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
df.groupby with duplicate columns in
by
works withagg
when a dictionary is passed in for aggregation function, but fails when pd.NamedAgg is used to provide aggregation functions.Expected Behavior
Should work, and have a similar output as passing in a dictionary.
Installed Versions
INSTALLED VERSIONS
commit : bdc79c1
python : 3.10.14.final.0
python-bits : 64
OS : Darwin
OS-release : 23.4.0
Version : Darwin Kernel Version 23.4.0: Fri Mar 15 00:12:49 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6020
machine : arm64
processor : arm
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 2.2.1
numpy : 1.26.4
pytz : 2024.1
dateutil : 2.9.0.post0
setuptools : 68.2.2
pip : 23.3.1
Cython : None
pytest : 7.4.4
hypothesis : None
sphinx : 5.0.2
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.3
IPython : 8.23.0
pandas_datareader : None
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.12.3
bottleneck : None
dataframe-api-compat : None
fastparquet : None
fsspec : 2024.3.1
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 16.0.0
pyreadstat : None
python-calamine : None
pyxlsb : None
s3fs : None
scipy : 1.13.0
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2024.1
qtpy : None
pyqt5 : None
The text was updated successfully, but these errors were encountered: