'How to analyze panel data, by decade and firm id

So heres the background. I have panel data. 1972-2020. I have 1 dependent variable (inflation) and 5 independent variables, imp, exp, tra, gro, pro. I have 10 countries. 5 small and 5 big ones, numbered 1-5 and 6-10.

I want to show the independend variables effect on the dependendt variable, sorted by decade (70,80,90,00,10) for each country. SO the output can tell us how the regression coefficentsenter image description here differs for each country for each decade.



Solution 1:[1]

Use:

df["A"].fillna(1 , inplace=True) # for col A - NaN -> 1
df["B"].fillna(0 , inplace=True) # for col B - NaN -> 0

Solution 2:[2]

This does it in one line

(df['column_name'].fillna(0,inplace=True),df['column_name'].fillna(1,inplace=True))
print(df)

Solution 3:[3]

fillna method also exists for Series objects.

df["A"] = df["A"].fillna(1)
df["B"] = df["B"].fillna(0)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sibtain Reza
Solution 2 Robin Sage
Solution 3