-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: Different types of group keys when grouping over one or multiple columns #46659
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
Comments
Thanks for report! @jankislinger Please make the title of this issue more specific. It will help others grasp your problem easier. But here I wonder that when will the current behavior lead to an error? Or is there a real situation you want np.int64 instead of int? |
I've been passing it to (sorry about the name, I didn't notice) |
json does not recognize NumPy data types. Convert the number to a Python int before serializing the object.
import pandas as pd |
Thanks @jankislinger for the report.
doesn't give an indication of which is correct, but yes the return types should be consistent. I guess returning Python types is more useful. (IIRC there are other issues discussing methods that should return Python types) |
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
When iterating over groups from single integer column the iterator yields the group values as Python integers. When you iterate over groups from multiple columns the type remains
np.int64
.Expected Behavior
I would expect both cases to have the same type
Installed Versions
INSTALLED VERSIONS
commit : 4bfe3d0
python : 3.10.4.final.0
python-bits : 64
OS : Linux
OS-release : 5.13.0-39-generic
Version : #44~20.04.1-Ubuntu SMP Thu Mar 24 16:43:35 UTC 2022
machine : x86_64
processor :
byteorder : little
LC_ALL : None
LANG : C.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.4.2
numpy : 1.22.3
pytz : 2022.1
dateutil : 2.8.2
pip : 22.0.4
setuptools : 58.1.0
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : None
brotli : None
fastparquet : None
fsspec : None
gcsfs : None
markupsafe : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
snappy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
zstandard : None
The text was updated successfully, but these errors were encountered: