I have a column of my dataframe that is made up of the following:
df['Year] = [2025, 2024, NaN, 2023, 2026, NaN] (these are type float64)
How can I convert these years to something in datetime format? Since there are no months or days included I feel like they have to output as [01-01-2025, 01-01-2021, NaT, 01-01-2023, 01-01-2026, NaT] by default.
But if there was a way to still have the column as [2025, 2024, NaT, 2023, 2026, NaT] then that would work well too.
Using df['Year'] = pd.DatetimeIndex(df['Year']).year just output [1970, 1970, NaN, 1970, 1970, NaN].
Thank you very much.