'Filling NaN values via specific column and specific category
I am coding in python and need some assistance. I have a dataframe and I want to fill each column with the average from each different category (pnns_group_1).

Currently I have the following code:

But my output is the average for the whole column, not the average per group:

So, to confirm I need the average from 'Cereals and potatoes' groups to be different from the average of 'Sugary snacks' groups. Thanks in advance for helping me with my problem.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
