-
-
Notifications
You must be signed in to change notification settings - Fork 19.1k
Description
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
import pandas as pd
subdf = pd.DataFrame({'My Column 1': []}, index=pd.to_datetime([], unit='s', utc=True))
df = pd.DataFrame()
df = df.join(subdf, how='outer')
df = df.resample("H").asfreq()
# output:
'''
<stdin>:1: FutureWarning: 'H' is deprecated and will be removed in a future version, please use 'h' instead.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/xytxytxyt/.pyenv/versions/temp/lib/python3.11/site-packages/pandas/core/generic.py", line 9771, in resample
return get_resampler(
^^^^^^^^^^^^^^
File "/Users/xytxytxyt/.pyenv/versions/temp/lib/python3.11/site-packages/pandas/core/resample.py", line 2050, in get_resampler
return tg._get_resampler(obj, kind=kind)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/xytxytxyt/.pyenv/versions/temp/lib/python3.11/site-packages/pandas/core/resample.py", line 2272, in _get_resampler
raise TypeError(
TypeError: Only valid with DatetimeIndex, TimedeltaIndex or PeriodIndex, but got an instance of 'RangeIndex'
'''
Issue Description
see the example
interestingly, this does not happen without the join()
:
import pandas as pd
df = pd.DataFrame({'My Column 1': []}, index=pd.to_datetime([], unit='s', utc=True))
df = df.resample("H").asfreq()
# output:
# <stdin>:1: FutureWarning: 'H' is deprecated and will be removed in a future version, please use 'h' instead.
Expected Behavior
no error is raised
Installed Versions
INSTALLED VERSIONS
commit : 0691c5c
python : 3.11.8
python-bits : 64
OS : Darwin
OS-release : 22.6.0
Version : Darwin Kernel Version 22.6.0: Mon Apr 22 20:50:39 PDT 2024; root:xnu-8796.141.3.705.2~1/RELEASE_ARM64_T8103
machine : arm64
processor : arm
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 2.2.3
numpy : 2.1.2
pytz : 2024.2
dateutil : 2.9.0.post0
pip : 24.2
Cython : None
sphinx : None
IPython : None
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : None
blosc : None
bottleneck : None
dataframe-api-compat : None
fastparquet : None
fsspec : None
html5lib : None
hypothesis : None
gcsfs : None
jinja2 : None
lxml.etree : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
psycopg2 : None
pymysql : None
pyarrow : None
pyreadstat : None
pytest : None
python-calamine : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlsxwriter : None
zstandard : None
tzdata : 2024.2
qtpy : None
pyqt5 : None