Python century date process

I have a data with century date format below:

date
0320316
NaN
1201102

I import the field to be str.

What I want is:

date         date_new
0320316      19320316
NaN               NaN
1201102      20201102

I tried:

df["date_new"] = df[["date"]].apply(lambda x: (str((x[0:4].astype(int) + 1900)) + x[4:]) if (x.notnull() == True) else x, axis = 1)

However, I got ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

Did I miss anything?

Answer

Fix your code

df["date"].apply(lambda x: (str((int(x[0:3]) + 1900)) + x[3:]) if (pd.isna(x) == False) else x)
Out[47]: 
0    19320316
1         NaN
2    20201102
Name: date, dtype: object