I have the following data frame
year month day
1990 05 23
nan nan nan
1991 06 24
1992 07 nan
1993 08 26
nan nan nan
I need to add a column called birthday with the values as the combined value only when all three columns have values
birthday
1990-05-23
nan
1991-06-24
nan
1993-08-26
nan
I'm creating the column birthday as
en["birthday"] = en["year"].astype(int).astype(str) + '-' + en["month"].astype(int).astype(str) + '-' + en["day"].astype(int).astype(str)
I'm running into a Cannot convert non-finite values (NA or inf) to integer
What is the best way to handle this ? Here, I haven't implemented a check to see if all of them have values either
The dataframe has other columns as well, so would prefer to avoid any global operations that could affect other columns
Using a fillna does help, but I would prefer the empty values as nan