Get some usable vector representations of datetime
Project description
timevec
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)
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.
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.
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.
Others
long_time_vec
... 1 to 5001 years periodmillenium_vec
... one millenium (1000 years) periodcentury_vec
... one century (100 years) perioddecade_vec
... one decade (10 years) period
License
BSD 3-Clause License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file timevec-0.1.5.tar.gz
.
File metadata
- Download URL: timevec-0.1.5.tar.gz
- Upload date:
- Size: 53.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15af8d06cd71b8d63a3627bde9cc98f0e60fbcd5fe07b665826f473491fd3606 |
|
MD5 | b8a0682fa8609dc020229428c5ff84de |
|
BLAKE2b-256 | 8d7799a5ac975c97dd33adb965da91160bb099bab4ea06c2d6d0381f347bffa5 |
File details
Details for the file timevec-0.1.5-py3-none-any.whl
.
File metadata
- Download URL: timevec-0.1.5-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d238f10216e12c5781c41b3349011bd1188233cef08492b3bddc6c941502178a |
|
MD5 | 979fc79f765a7032d807e6fdea0809b0 |
|
BLAKE2b-256 | 8661f5565bbbbf91412d9bcfc21cc31cde74f0bba1dd6343c96459053e371a2b |