I have a pandas DataFrame like this:
year = [2015, 2016, 2009, 2000, 1998, 2017, 1980, 2016, 2015, 2015]
mode = ["automatic", "automatic", "manual", "manual", np.nan,'automatic', np.nan, 'automatic', np.nan, np.nan]
X = pd.DataFrame({'year': year, 'mode': mode})
print(X)
year mode
0 2015 automatic
1 2016 automatic
2 2009 manual
3 2000 manual
4 1998 NaN
5 2017 automatic
6 1980 NaN
7 2016 automatic
8 2015 NaN
9 2015 NaN
I want to fill missing values with like this: if year is <2010 I want to fill NaN with 'manual' and if year is >=2010 I want to fill NaN value with 'automatic'
I thought about combination .groupby function with these condition but I do not know honestly how to do it :(
I would be grateful for any help.