library(tidyverse)
library(readxl)
library(zoo)
library(padr)
input = read_excel("files/CH-062 Missing Values.xlsx", range = "B2:D21")
test = read_excel("files/CH-062 Missing Values.xlsx", range = "H2:J38")
result = input %>%
mutate(Date = Date + days(1)) %>%
group_by(Project) %>%
pad() %>%
mutate(`Actual Progress` = na.approx(`Actual Progress`)) %>%
ungroup() %>%
mutate(Date = Date - days(1))
all.equal(test,result)
#> [1] TRUEOmid - Challenge 62
data-challenges
advanced-exercises
🔰 The progress for month 8 is missing, so the average of the progress values for months 7 and 9 is used.

Challenge Description
🔰 The progress for month 8 is missing, so the average of the progress values for months 7 and 9 is used.
Solutions
Logic:
Reads the workbook ranges needed for the challenge
Aggregates or ranks values at the relevant grouping level
Builds the intermediate columns that drive the final result
Strengths:
- The R solution stays close to the workbook rule and keeps the transformation compact.
Areas for Improvement:
- The code assumes the sheet structure and source ranges remain stable.
Gem:
- The strongest part of the solution is choosing the right intermediate representation before shaping the final output.
import pandas as pd
from datetime import timedelta
from scipy.interpolate import interpolate
input = pd.read_excel("CH-062 Missing Values.xlsx", usecols="B:D", skiprows=1, nrows=19)
test = pd.read_excel("CH-062 Missing Values.xlsx", usecols="H:J", skiprows=1)
test.columns = test.columns.str.replace('.1', '')
input["Date"] = pd.to_datetime(input["Date"]) + timedelta(days=1)
all_dates = pd.date_range(start=input["Date"].min(), end=input["Date"].max(), freq='MS')
all_dates = pd.DataFrame(all_dates, columns=["Date"])
all_dates["Date"] = pd.to_datetime(all_dates["Date"]) - timedelta(days=1)
input["Date"] = pd.to_datetime(input["Date"]) - timedelta(days=1)
all_projects = pd.DataFrame(input["Project"].unique(), columns=["Project"])
all_dates["key"] = 0
all_projects["key"] = 0
all_dates = all_dates.merge(all_projects, on="key").drop(columns=["key"]).sort_values(["Project","Date"]).reset_index().drop(columns="index")
all_dates = all_dates.merge(input, on=["Project","Date"], how="left")
all_dates["Actual Progress"] = all_dates.groupby("Project")["Actual Progress"].transform(lambda x: x.interpolate())
print(all_dates["Actual Progress"].round(4).equals(test["Actual Progress"].round(4)))Logic:
Reads the workbook ranges needed for the challenge
Aggregates or ranks values at the relevant grouping level
Strengths:
- The Python version follows the same rule in a direct dataframe-oriented implementation.
Areas for Improvement:
- The code assumes the workbook layout remains stable, so any sheet redesign would require small adjustments.
Gem:
- The implementation stays close to the original workbook rule instead of adding unnecessary abstraction.
Difficulty Level
This task is moderate:
The core logic is clear, but the correct transformation pattern is not obvious from the raw input.
The challenge combines multiple reshaping, grouping, or parsing steps.