You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Doing groupby() on a Series, with a DatetimeIndex and a name that is a month abbreviation
triggers an attempt to convert the name into a DateTime, which fails/throws.
Either using integer index or having a non month name avoids the issue.
It was reproduced on both MacOS and Windows.
(The issue showed up in a DataFrame.apply(), where the column name happened to be a month name)
Expected Behavior
It is expected that the column name is left as is.
I just noticed the above has version 1.4.3, I double checked the same results happens with 1.4.4
maartenb
changed the title
BUG:
BUG: groupby() attempts to converts name of Series if name is a month
Sep 12, 2022
maartenb
changed the title
BUG: groupby() attempts to converts name of Series if name is a month
BUG: groupby() attempts to converts name of Series if name is a month and index is DateTime
Sep 12, 2022
Hi, I ran into this bug too and did some investigations.
The error is pandas._libs.tslibs.np_datetime.OutOfBoundsDatetime: Out of bounds nanosecond timestamp: 1-01-01 00:00:00.
The problem comes from the line below. When obj is a Series with DatetimeIndex and gpr.name is a str like 'Jan', obj[gpr.name] will call DatetimeIndex.get_loc('Jan'), parsing 'Jan' into an invalid timestamp.
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
Doing groupby() on a Series, with a DatetimeIndex and a name that is a month abbreviation
triggers an attempt to convert the name into a DateTime, which fails/throws.
Either using integer index or having a non month name avoids the issue.
It was reproduced on both MacOS and Windows.
(The issue showed up in a DataFrame.apply(), where the column name happened to be a month name)
Expected Behavior
It is expected that the column name is left as is.
Installed Versions
INSTALLED VERSIONS
commit : e8093ba
python : 3.10.6.final.0
python-bits : 64
OS : Darwin
OS-release : 20.6.0
Version : Darwin Kernel Version 20.6.0: Tue Jun 21 20:50:28 PDT 2022; root:xnu-7195.141.32~1/RELEASE_X86_64
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : None
LOCALE : en_US.UTF-8
pandas : 1.4.3
numpy : 1.23.1
pytz : 2022.1
dateutil : 2.8.2
setuptools : 63.4.1
pip : 22.1.2
Cython : None
pytest : 7.1.2
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : 2.8.6
jinja2 : None
IPython : None
pandas_datareader: None
bs4 : 4.11.1
bottleneck : 1.3.5
brotli :
fastparquet : None
fsspec : None
gcsfs : None
markupsafe : None
matplotlib : 3.5.2
numba : None
numexpr : 2.8.3
odfpy : None
openpyxl : 3.0.10
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
snappy : None
sqlalchemy : 1.4.39
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
zstandard : None
The text was updated successfully, but these errors were encountered: