API
dateint.add(date, *, years=0, months=0, days=0)
Add some time interval to a formatted date/datetime.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
date
|
Union[Series, int, str, float]
|
a series of formatted dates/datetimes, or a single formatted date/datetime. |
required |
years
|
int
|
number of years to add. Defaults to 0. |
0
|
months
|
int
|
number of months to add. Defaults to 0. |
0
|
days
|
int
|
number of days to add. Defaults to 0. |
0
|
Examples:
import dateint as di
import pandas as pd
di.add(20220510, days=15)
# 20220525
dates = pd.Series([202201, 202202, 202203])
di.add(dates, months=2)
'''
0 202203
1 202204
2 202205
dtype: int64
'''
Returns:
| Type | Description |
|---|---|
Union[Series, int, str, float]
|
a series of formatted dates/datetimes, or a single formatted date/datetime. |
dateint.sub(date, *, years=0, months=0, days=0)
Subtract some time interval from a formatted date/datetime.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
date
|
Union[Series, int, str, float]
|
a series of formatted dates/datetimes, or a single formatted date/datetime. |
required |
years
|
int
|
number of years to subtract. Defaults to 0. |
0
|
months
|
int
|
number of months to subtract. Defaults to 0. |
0
|
days
|
int
|
number of days to subtract. Defaults to 0. |
0
|
Examples:
import dateint as di
import pandas as pd
di.sub(20220510, days=8)
# 20220502
dates = pd.Series([202201, 202202, 202203])
di.sub(dates, years=1)
'''
0 202101
1 202102
2 202103
dtype: int64
'''
Returns:
| Type | Description |
|---|---|
Union[Series, int, str, float]
|
a series of formatted dates/datetimes, or a single formatted date/datetime. |
dateint.today()
Return current date as an integer, formatted as %Y%m%d.
Returns:
| Type | Description |
|---|---|
int
|
Current date as an integer, formatted as %Y%m%d. |
dateint.weekday(date)
Return day of week as returned by datetime.datetime.weekday() method.
Return the day of week as an integer, where Monday is 0 and Sunday is 6.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
date
|
Union[Series, int, str, float]
|
a series of formatted dates/datetimes, or a single formatted date/datetime. |
required |
Returns:
| Type | Description |
|---|---|
Union[Series, int]
|
day of week (from 0 to 6) |
dateint.isoweekday(date)
Return day of week as returned by datetime.datetime.isoweekday() method.
Return the day of week as an integer, where Monday is 1 and Sunday is 7.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
date
|
Union[Series, int, str, float]
|
a series of formatted dates/datetimes, or a single formatted date/datetime. |
required |
Returns:
| Type | Description |
|---|---|
Union[Series, int]
|
day of week (from 1 to 7) |