AadityaAnand commented on code in PR #42678:
URL: https://github.com/apache/superset/pull/42678#discussion_r3712721818


##########
superset/utils/pandas_postprocessing/resample.py:
##########
@@ -47,7 +55,18 @@ def resample(
         )
 
     if method == "asfreq" and fill_value is not None:
-        _df = df.resample(rule).asfreq(fill_value=fill_value)
+        origin = time_range_start if time_range_start is not None else 
"start_day"
+        _df = df.resample(rule, origin=origin).asfreq(fill_value=fill_value)
+        if time_range_start is not None and time_range_end is not None:
+            # Zero-filling should cover the entire queried time range, not
+            # just the span between the first and last existing data points.
+            full_index = pd.date_range(
+                start=time_range_start,
+                end=time_range_end,
+                freq=rule,
+                inclusive="left",
+            )
+            _df = _df.reindex(full_index, fill_value=fill_value)

Review Comment:
   Thanks for the review. I updated the implementation to preserve the 
resampler’s existing bucket labels while extending the index rather than 
replacing it. This avoids dropping legitimate buckets for calendar-based 
frequencies such as month, quarter, and year start. Regression tests have been 
added for these scenarios.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to