harbor run -t openthoughts/tasktrove-exp-rpt-curriculum-medium-curriculum-medium-0232harbor download openthoughts/tasktrove-exp-rpt-curriculum-medium-curriculum-medium-0232Here is a MEDIUM-difficulty rewrite of the task. It keeps the same Python/GP-topic and the core API, but adds clarifications, a couple of moderate edge cases, and gentle input validation. You should implement it as a single-file task placed under /app/.
Goal
Deliverable location
What to implement (symbols and behavior)
first(x: pd.Series) -> pd.Series
last(x: pd.Series) -> pd.Series
last_value(x: pd.Series) -> float
count(x: pd.Series) -> pd.Series
diff(x: pd.Series, periods: int = 1) -> pd.Series
lag(x: pd.Series, lag: Union[int, str] = 1, mode: LagMode = LagMode.EXTEND) -> pd.Series
Core and delicate function. Implement a robust, well-documented version with the following semantics deduced from tests and examples:
Input:
Offset construction (normalized to a numeric timedelta-like offset):
Behavior by mode:
Special case hints (to align with tests):
Edge cases and validation:
Notes and tips
What you should deliver
A self-contained /app/gs_quant.py file implementing:
The module must expose gs_quant.timeseries when imported, via dynamic submodule registration, so tests can do from gs_quant.timeseries import first, last, etc.
Include docstrings and input validation to help maintainability and readability.
Ensure the API surface is stable and matches the signatures described above.