Pandas version checks

  • [X] I have checked that this issue has not already been reported.

  • [X] I have confirmed this bug exists on the latest version of pandas.

  • [X] I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import pandas as pd
df = pd.DataFrame([], index=pd.DatetimeIndex([]))

# this returns a MultiIndex rather than a DatetimeIndex
df.resample("D").ffill().index

Issue Description

When upsampling an empty dataframe, the index type changes from DatetimeIndex to MultiIndex.

This applies to all the upsampling methods, i.e. resample followed by fillna, ffill, bfill, nearest, asfreq, or interpolate.

This only happens on empty dataframes or series, and only when upsampling (for example resample("D").mean() works as expected).

This regression was introduced in pandas 2.0.0

Expected Behavior

The resampled dataframe should have a DatetimeIndex rather than a MultiIndex.

Installed Versions

pandas : 2.1.1 numpy : 1.26.0 pytz : 2023.3.post1 dateutil : 2.8.2 setuptools : 68.2.2 pip : 23.3 tzdata : 2023.3

all others None

Comment From: creid-hartree

Perhaps related to these two (fixed) issues: https://github.com/pandas-dev/pandas/issues/47705 https://github.com/pandas-dev/pandas/issues/53664

Comment From: Charlie-XIAO

take