I have a DataFrame with column3 containing NaN values. I want to replace these NaN values with column2-column1. But column 2 is a string and I want to take the first four digits from the string and convert it to integer before subracting.
I tried this:
df.column3.fillna(int(df.column2[:4]) - df.column1)
And I get this following error:
TypeError: cannot convert the series to <class 'int'>