79513733

Date: 2025-03-17 06:09:56
Score: 2
Natty:
Report link

As change the method by make grouping all the NAN fields with year ,month and week and it will work.

df['week'] = df['day'].apply(lambda x: (x - 1) // 7 + 1) # Assign week numbers

df['C'] = df.groupby(['year', 'month', 'week'])['C'].transform(lambda x: x.ffill().bfill())

Reasons:
  • Low length (0.5):
  • No code block (0.5):
  • Low reputation (1):
Posted by: Jinit Trivedi