Helper library for manipulation of formatted date/datetime values
It's very common to store date/datetimes as integers or strings using formats
such as YYYYmmdd
or YYYYmm
. In python, to perform date/datetime arithmetic on those
values, one needs to:
- convert the original value to
date
ordatetime
- perform the date/datetime operation
- convert the result back to the original format
With dateint
, we abstract all convertion operations so you can focus on the
arithmetic step:
-
single value:
import dateint as di di.add(20220510, days=15) # 20220525
-
pandas:
import dateint as di import pandas as pd dates = pd.Series([202201, 202202, 202203]) di.add(dates, months=2) ''' 0 202203 1 202204 2 202205 dtype: int64 '''
See the documentation page for the complete and detailed documentation.
pip install dateint