Extract the year from a date data In pandas

PHOTO EMBED

Mon Sep 05 2022 09:56:58 GMT+0000 (Coordinated Universal Time)

Saved by @DataSynapse82 #python #pandas #dataset #eda #extractyear #datetime

df['year'] = df['date'].dt.year if we put dt.month is for month etc..
df.head()
content_copyCOPY

Year extraction from a dataframe column.