Skip to content

PeriodUnit Source

Bases: Enum

Lengths of the periods DatePeriod groups dates by, such as the month or the week.

Added in version 0.1.0

Examples:

from datetime import datetime
import numdaplot as ndp

times = ndp.Array.from_list([datetime(2026, 12, 31, 14, 30)])
times.apply(ndp.DatePeriod(unit=ndp.PeriodUnit.MONTH))
# Array(['2026-12-01'], dtype=DATE)

Attributes

YEAR = auto() Source

The year, starting on January 1.

Added in version 0.1.0

Examples:

from datetime import datetime
import numdaplot as ndp

times = ndp.Array.from_list([datetime(2026, 12, 31, 14, 30)])
times.apply(ndp.DatePeriod(unit=ndp.PeriodUnit.YEAR))
# Array(['2026-01-01'], dtype=DATE)

QUARTER = auto() Source

The quarter, starting on January 1, April 1, July 1 or October 1.

Added in version 0.1.0

Examples:

from datetime import datetime
import numdaplot as ndp

times = ndp.Array.from_list([datetime(2026, 12, 31, 14, 30)])
times.apply(ndp.DatePeriod(unit=ndp.PeriodUnit.QUARTER))
# Array(['2026-10-01'], dtype=DATE)

MONTH = auto() Source

The month, starting on its first day.

Added in version 0.1.0

Examples:

from datetime import datetime
import numdaplot as ndp

times = ndp.Array.from_list([datetime(2026, 12, 31, 14, 30)])
times.apply(ndp.DatePeriod(unit=ndp.PeriodUnit.MONTH))
# Array(['2026-12-01'], dtype=DATE)

WEEK = auto() Source

The week, starting on Monday.

Added in version 0.1.0

Examples:

from datetime import datetime
import numdaplot as ndp

times = ndp.Array.from_list([datetime(2026, 12, 31, 14, 30)])
times.apply(ndp.DatePeriod(unit=ndp.PeriodUnit.WEEK))
# Array(['2026-12-28'], dtype=DATE)

DAY = auto() Source

The day.

Added in version 0.1.0

Examples:

from datetime import datetime
import numdaplot as ndp

times = ndp.Array.from_list([datetime(2026, 12, 31, 14, 30)])
times.apply(ndp.DatePeriod(unit=ndp.PeriodUnit.DAY))
# Array(['2026-12-31'], dtype=DATE)

HOUR = auto() Source

The hour, starting at minute 0. Datetimes only, the result is a DATETIME.

Added in version 0.1.0

Examples:

from datetime import datetime
import numdaplot as ndp

times = ndp.Array.from_list([datetime(2026, 12, 31, 14, 30)])
times.apply(ndp.DatePeriod(unit=ndp.PeriodUnit.HOUR))
# Array(['2026-12-31 14:00:00'], dtype=DATETIME)