Skip to content

BUG: resample on empty DataFrame leads to ValueError #52484

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

Closed
ASchueddekopf opened this issue Apr 6, 2023 · 3 comments · Fixed by #52615
Closed

BUG: resample on empty DataFrame leads to ValueError #52484

ASchueddekopf opened this issue Apr 6, 2023 · 3 comments · Fixed by #52615
Assignees
Labels
Regression Functionality that used to work in a prior pandas version Resample resample method
Milestone

Comments

@ASchueddekopf
Copy link

ASchueddekopf commented Apr 6, 2023

Before version 2.0.0 I was able to resample an empty DataFrame with DateTimeIndex. Now it leads to a ValueError. Is that on purpose or a bug?

@MarcoGorelli
Copy link
Member

can you show a reproducible example please?

@mroeschke mroeschke added the Needs Info Clarification about behavior needed to assess issue label Apr 6, 2023
@ASchueddekopf
Copy link
Author

If you create a python file with the following code it will result in a df with 15 min frequency datetimeIndex with pandas version 1.5.2 and a value error with pandas 2.0.0:

import datetime
import pandas as pd

def main():
    year = 2018
    freq = "1H"

    index = pd.date_range(
            start=datetime.datetime(year, 1, 1),
            end=datetime.datetime(year + 1, 1, 1),
            freq=freq,
        )
    index = index[:-1]
    index = pd.to_datetime(index)

    df = pd.DataFrame(index=index)
    df.resample("15Min").mean()

if __name__ == "__main__":
    main()

@MarcoGorelli
Copy link
Member

@MarcoGorelli MarcoGorelli added Regression Functionality that used to work in a prior pandas version and removed Needs Info Clarification about behavior needed to assess issue labels Apr 11, 2023
@phofl phofl added this to the 2.0.1 milestone Apr 11, 2023
@phofl phofl added the Resample resample method label Apr 11, 2023
@rhshadrach rhshadrach self-assigned this Apr 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Regression Functionality that used to work in a prior pandas version Resample resample method
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants