-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
BUG: resample with asfreq ignores origin if the dataframe has a fixed frequency #62725 #62763
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
Changes from 4 commits
1a36f56
34e7d10
f0442ba
eb00fe8
68d2491
3a3b6fb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -989,3 +989,27 @@ def test_resample_empty(): | |
| ) | ||
| result = df.resample("8h").mean() | ||
| tm.assert_frame_equal(result, expected) | ||
|
|
||
|
|
||
| def test_asfreq_respects_origin_with_fixed_freq_all_seconds_equal(): | ||
| # GH#62725: Ensure Resampler.asfreq respects origin="start_day" | ||
| # when all datetimes share identical seconds values. | ||
| idx = [ | ||
| datetime(2025, 10, 17, 17, 15, 10), | ||
| datetime(2025, 10, 17, 17, 16, 10), | ||
| datetime(2025, 10, 17, 17, 17, 10), | ||
| ] | ||
| df = DataFrame({"value": [0, 1, 2]}, index=idx) | ||
|
|
||
| result = df.resample("1min", origin="start_day").asfreq() | ||
|
|
||
| # Expected index: match dtype while preserving freq | ||
| exp_idx = pd.DatetimeIndex( | ||
| date_range("2025-10-17 17:15:00", periods=3, freq="min").astype( | ||
| result.index.dtype | ||
| ), | ||
|
||
| freq="min", | ||
| ) | ||
|
|
||
| exp = DataFrame({"value": [np.nan, np.nan, np.nan]}, index=exp_idx) | ||
| tm.assert_frame_equal(result, exp) | ||
Uh oh!
There was an error while loading. Please reload this page.