In Pandas, pd.to_datetime()
function can be used to convert a column to datetime. It can parse a wide variety of date formats including format codes representing hours.
To parse hours, you can use %H
format code, which represents 24 hour format (00–23). Here's an example:
main.py206 chars10 lines
Output:
main.py88 chars5 lines
In this example, we converted the Time
column which has format hh:mm
to a datetime column by specifying the format as %H:%M
.
gistlibby LogSnag