wenmin-wu/ds-skills/neighbor-average-nan-interpolation
Claude Code and agent skill by wenmin-wu/ds-skills
- community
Checking that the SKILL.md file is still in the repository.
Fill gaps in a daily exogenous series (oil prices, sensor feeds) by merging against a full calendar to expose NaNs, then replacing each NaN with the midpoint of its nearest valid left and right neighbors, walking outward past consecutive NaN runs
Install
npx vskill@latest install wenmin-wu/ds-skills/neighbor-average-nan-interpolationSKILL.md
Overview
When you merge a sparse daily series (oil price, weather) against a full calendar for forecasting features, weekends and holidays become NaN rows that break downstream models. ffill propagates Monday's value across Sunday, biasing weekend-sensitive signals; interpolate() handles short gaps but silently skips leading/trailing NaNs. The midpoint-neighbor recipe is the deterministic workhorse: build the full calendar, expose NaN positions, walk outward past any consecutive NaN run to find the next valid value on each side, and assign the midpoint. Edge NaNs fall back to the single available neighbor.
Quick Start
Workflow
- Build a complete
date_rangecalendar spanning the forecast horizon - Left-merge the sparse series onto the calendar so all gaps become explicit NaN rows
- Collect integer indices of every NaN position
- For each NaN, walk left and right past consecutive NaN runs to find the nearest valid neighbors
- Assign the midpoint of left + right values; fall back to the single available neighbor for boundary NaNs
Key Decisions
- Midpoint vs distance-weighted linear: midpoint is cheaper and nearly indistinguishable for short gaps in near-stationary signals. Use
pandas.interpolate(method='time')for long gaps or strong trends. - Full calendar merge is mandatory: without it, weekend/holiday gaps are invisible and
fillnawon't touch them. - Boundary fallback: leading/trailing NaN must copy the one available neighbor — otherwise you get out-of-bounds or NaN leakage into the model.
- Integer index, not date index: walking outward with
.loc[i]requires a sequential integer index, soreset_index(drop=True)after the merge. - Don't use `ffill` for weekends: it propagates Friday's value through Sunday, which is exactly wrong for weekend-sensitive signals.
References
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/timeseries/neighbor-average-nan-interpolation/SKILL.md
Popularity
- 7-day trend score
- 5
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/wenmin-wu/ds-skills/neighbor-average-nan-interpolation)