timevec


Nametimevec JSON
Version 0.2.0 PyPI version JSON
download
home_pagehttps://github.com/kitsuyui/python-timevec
SummaryGet some usable vector representations of datetime
upload_time2023-10-06 05:34:08
maintainer
docs_urlNone
authorYui Kitsu
requires_python>=3.8
licenseBSD-3-Clause
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # timevec

[![python versions](https://img.shields.io/pypi/pyversions/timevec)](https://pypi.org/project/timevec/)
[![package version](https://img.shields.io/pypi/v/timevec)](https://pypi.org/project/timevec/#history)
[![codecov](https://codecov.io/gh/kitsuyui/python-timevec/branch/main/graph/badge.svg?token=38BQRO1R00)](https://codecov.io/gh/kitsuyui/python-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

```sh
pip install timevec
```

# Usage

```python
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

```python
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](https://user-images.githubusercontent.com/2596972/213921526-f59c44d1-22c1-4649-88ca-5f50b8d85765.svg)

## month_vec

```python
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](https://user-images.githubusercontent.com/2596972/213921552-6369b8f0-6eff-42fd-8f9f-42a9ad62f2b8.svg)


## week_vec

```python
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](https://user-images.githubusercontent.com/2596972/213921560-eb7b4e6d-bfc7-487a-926b-2810365ba8d8.svg)


## day_vec

```python
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](https://user-images.githubusercontent.com/2596972/213921566-dd69416e-2816-4c3d-9808-b3f87a51e543.svg)


## 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

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/kitsuyui/python-timevec",
    "name": "timevec",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "",
    "author": "Yui Kitsu",
    "author_email": "kitsuyui+github@kitsuyui.com",
    "download_url": "https://files.pythonhosted.org/packages/a7/c8/e5cad7cc8e27cf04d732466f17d4e4b3eca7170eb0fe265f7bba838e82b7/timevec-0.2.0.tar.gz",
    "platform": null,
    "description": "# timevec\n\n[![python versions](https://img.shields.io/pypi/pyversions/timevec)](https://pypi.org/project/timevec/)\n[![package version](https://img.shields.io/pypi/v/timevec)](https://pypi.org/project/timevec/#history)\n[![codecov](https://codecov.io/gh/kitsuyui/python-timevec/branch/main/graph/badge.svg?token=38BQRO1R00)](https://codecov.io/gh/kitsuyui/python-timevec)\n\nFunctions to create time vectors\n\n# Description\n\nTime has a periodic nature due to the rotation of the earth and the position of the sun.\nThis affects human behavior in various ways.\n\n- Seasonality ... periodicity in a year (seasonal distinction)\n- Daily periodicity ... periodicity in a day (distinction between day and night)\n- Day of the week ... periodicity in a week (distinction between weekdays and holidays)\n\nWhen dealing with these, it is desirable to vectorize with periodicity in mind.\nThat is, at 23:59 on a given day, it is desirable that the value is close to 00:00 on the next day.\nTo achieve this, the time is represented as a combination of cos and sin.\nThis is called a time vector.\n\n# Installation\n\n```sh\npip install timevec\n```\n\n# Usage\n\n```python\nimport timevec.numpy as tv\nimport datetime\ndt = datetime.datetime(2020, 1, 1, 0, 0, 0)\nvec = tv.year_vec(dt)\n# array([1., 0.])\n```\n\n# Modules\n\n- `timevec.numpy` provides functions that return numpy.ndarray.\n- `timevec.numpy_datetime64` provides functions that return numpy.datetime64.\n- `timevec.builtin_math` provides functions that return tuple of float.\n\n# Functions\n\nAlmost same functions are provided in `timevec.numpy`, `timevec.numpy_datetime64`, and `timevec.builtin_math`.\nThe difference is the return type.\n\n## year_vec\n\n```python\nyear_vec(dt: datetime.datetime)\n```\n\nCreate a time vector for a year.\nThis is a vector that has periodicity like seasonality.\n(Summer, Autumn, Winter, Spring)\n![year_vec](https://user-images.githubusercontent.com/2596972/213921526-f59c44d1-22c1-4649-88ca-5f50b8d85765.svg)\n\n## month_vec\n\n```python\nmonth_vec(dt: datetime.datetime)\n```\n\nCreate a time vector for a month.\nThis is a vector that has periodicity in a month.\nYou can express periodicity such as the beginning of the month, the end of the month, and the salary day.\n![month_vec](https://user-images.githubusercontent.com/2596972/213921552-6369b8f0-6eff-42fd-8f9f-42a9ad62f2b8.svg)\n\n\n## week_vec\n\n```python\nweek_vec(dt: datetime.datetime)\n```\n\nCreate a time vector for a week.\nThis is a vector that has periodicity in a week.\nYou can express periodicity such as weekdays and holidays.\n![week_vec](https://user-images.githubusercontent.com/2596972/213921560-eb7b4e6d-bfc7-487a-926b-2810365ba8d8.svg)\n\n\n## day_vec\n\n```python\nday_vec(dt: datetime.datetime)\n```\n\nCreate a time vector for a day.\nThis is a vector that has periodicity in a day.\nYou can express periodicity such as morning, noon, and night.\n![day_vec](https://user-images.githubusercontent.com/2596972/213921566-dd69416e-2816-4c3d-9808-b3f87a51e543.svg)\n\n\n## Others\n\n- `long_time_vec` ... 1 to 5001 years period\n- `millennium_vec` ... one millennium (1000 years) period\n- `century_vec` ... one century (100 years) period\n- `decade_vec` ... one decade (10 years) period\n\n# License\n\nBSD 3-Clause License\n",
    "bugtrack_url": null,
    "license": "BSD-3-Clause",
    "summary": "Get some usable vector representations of datetime",
    "version": "0.2.0",
    "project_urls": {
        "Homepage": "https://github.com/kitsuyui/python-timevec"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7d9851819013decd06d325d2bcadd573800d6ff91fe18ae24e86a53b62955d0b",
                "md5": "320787842a45c2b0bfee9fd5897268b3",
                "sha256": "036e3fcdebd52965dad00792efe2a3dc86c95b479b9edccb5def5225031afe17"
            },
            "downloads": -1,
            "filename": "timevec-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "320787842a45c2b0bfee9fd5897268b3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 8663,
            "upload_time": "2023-10-06T05:34:06",
            "upload_time_iso_8601": "2023-10-06T05:34:06.615445Z",
            "url": "https://files.pythonhosted.org/packages/7d/98/51819013decd06d325d2bcadd573800d6ff91fe18ae24e86a53b62955d0b/timevec-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a7c8e5cad7cc8e27cf04d732466f17d4e4b3eca7170eb0fe265f7bba838e82b7",
                "md5": "aa849acf65c9c792abf803c809a1f5b3",
                "sha256": "f42fdd1b494cae0a121c01a6f4d50f3b8ea6e6379852ba74e5255f9bcb17abaf"
            },
            "downloads": -1,
            "filename": "timevec-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "aa849acf65c9c792abf803c809a1f5b3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 60912,
            "upload_time": "2023-10-06T05:34:08",
            "upload_time_iso_8601": "2023-10-06T05:34:08.371077Z",
            "url": "https://files.pythonhosted.org/packages/a7/c8/e5cad7cc8e27cf04d732466f17d4e4b3eca7170eb0fe265f7bba838e82b7/timevec-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-06 05:34:08",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "kitsuyui",
    "github_project": "python-timevec",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "timevec"
}
        
Elapsed time: 0.12400s