DekGenius.com
Home
(current)
Dictionary
BOOKS
LYRICS
CHORD
SCRIPT & CODE EXAMPLE
Karaoke language
Search
Go
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
COMMENT
Name
1+5 =
Submit