Ben Chuanlong Du's Blog

It is never too late to learn.

Python Modules for Date and Time

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

datetime

dateutil

Useful extensions to the standard Python datetime features

dateparser

python parser for human readable dates

arrow

Better dates & times for Python.

monthdelta

Hands on the datetime Module in Python

Comment

A Datetime object cannot be compared with a string directly. However, pandas Series of datetime objects can be compared with string date directly (both by operators and methods). The comparison is done by parsing the string to a datetime object. An exception will be thrown if the string cannot be parsed into a datetime object.

Date and Time in Python pandas

Date/time utilities in the pandas module are more flexible/powerful than that in the datetime module. It is suggested that you use date/time utilities in the pandas module when you use DataFrame/Series in the pandas module.

  1. pandas.to_datetime works on an iterable object, handles missing values and nano seconds.

  2. pandas.Series.dt.strftime