Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

pandas convert date column to year and month

df['StartDate'].dt.to_period('M')

result:

0    2021-08
1    2021-08
2    2021-08
Source by datascientyst.com #
 
PREVIOUS NEXT
Tagged: #pandas #convert #date #column #year #month
ADD COMMENT
Topic
Name
2+7 =