Skip to main content

timevec

python versions package version Coverage

Functions to create time vectors

Description

Time has a periodic nature due to the rotation of the earth and the position of the sun. This affects human behavior in various ways.

  • Seasonality ... periodicity in a year (seasonal distinction)
  • Daily periodicity ... periodicity in a day (distinction between day and night)
  • Day of the week ... periodicity in a week (distinction between weekdays and holidays)

When dealing with these, it is desirable to vectorize with periodicity in mind. That is, at 23:59 on a given day, it is desirable that the value is close to 00:00 on the next day. To achieve this, the time is represented as a combination of cos and sin. This is called a time vector.

Installation

pip install timevec

Usage

import timevec.numpy as tv
import datetime
dt = datetime.datetime(2020, 1, 1, 0, 0, 0)
vec = tv.year_vec(dt)
# array([1., 0.])

Modules

  • timevec.numpy provides functions that return numpy.ndarray.
  • timevec.numpy_datetime64 provides functions that return numpy.datetime64.
  • timevec.builtin_math provides functions that return tuple of float.

Functions

Almost same functions are provided in timevec.numpy, timevec.numpy_datetime64, and timevec.builtin_math. The difference is the return type.

year_vec

year_vec(dt: datetime.datetime)

Create a time vector for a year. This is a vector that has periodicity like seasonality. (Summer, Autumn, Winter, Spring) year_vec

month_vec

month_vec(dt: datetime.datetime)

Create a time vector for a month. This is a vector that has periodicity in a month. You can express periodicity such as the beginning of the month, the end of the month, and the salary day. month_vec

week_vec

week_vec(dt: datetime.datetime)

Create a time vector for a week. This is a vector that has periodicity in a week. You can express periodicity such as weekdays and holidays. week_vec

day_vec

day_vec(dt: datetime.datetime)

Create a time vector for a day. This is a vector that has periodicity in a day. You can express periodicity such as morning, noon, and night. day_vec

Others

  • long_time_vec ... 1 to 5001 years period
  • millennium_vec ... one millennium (1000 years) period
  • century_vec ... one century (100 years) period
  • decade_vec ... one decade (10 years) period

License

BSD 3-Clause License

Metadata

Release files for timevec 0.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for timevec 0.3.2
File Size Uploaded
timevec-0.3.2.tar.gz 126.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for timevec 0.3.2
File Interpreter ABI Platform
timevec-0.3.2-py3-none-any.whl Python 3 none any Details

Total release size: 136.4 kB

Release files / timevec-0.3.2.tar.gz

Download URL timevec-0.3.2.tar.gz
Size 126.6 kB
Tags Source
SHA-256 checksum
How to use checksums
0a8201b1ec21281020277b5da485b48e74ea073c84ae95621fe2d46d4f17b1ee
BLAKE2b-256 checksum
How to use checksums
cb4a7043e6919f10aca5ac6f4350c6124c031ed32fd51adfd1217b8e9700e45e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / timevec-0.3.2-py3-none-any.whl

Download URL timevec-0.3.2-py3-none-any.whl
Size 9.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2dde818570b9e08044efead2d107ca61b28048437fc239fad0af6287616c860b
BLAKE2b-256 checksum
How to use checksums
c3866c86d2e1730d1e620d1ea17f7c7ddb80ba012364c60861c93f00390d78f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release history Release notifications | RSS feed

This release

0.3.2 This release

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page