Skip to content

reindex(method="backfill") and periods within the last date #34

Closed
@tgefell

Description

@tgefell

I have a DataFrame with 1 minute timestamps, pw.

I have a monthly average of the values:
ma_pw=pw.groupby(BMonthEnd(+1).rollforward).aggregate(np.mean)

When I do a reindex to push that average back into all of the periods for the month,
the last day's values are NaN. Here's my reindex attempt:

reindexed = ma_pw.reindex(pw.index, method="backfill").

I have worked around this by forcing the hour in my monthly data to something past the last minute that I care about in my by-minute data as follows, but this seems incredibly crude:

from dateutil.relativedelta import *
newi = [x + relativedelta(hour=20) for x in ma_pw.index]
ma_pw.index = newi[:]

Then my original reindex works.

Is there a clean way to instruct the reindex method to include the datetime objects having the same datetime.date on that last day of the month?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions