Easy management of python datetime & pandas time Series
Project description
Easy management of python datetime & pandas time Series.
Created to be used in a project, this package is published to github for ease of management and installation across different modules.
Features
Provides two classes for datetime and pandas time series management.
pydt
(Python Datetime)pddt
(Pandas Time Series)
Both provide similar functionalities:
- Parse time string
- Access in different data types
- Conversion to
int/float
(ordinal, total_seconds, timestamp, etc.) - Calender properties (days_in_month, weekday, etc.)
- Day manipulation (next_week, to_week, etc.)
- Month manipulation (next_month, to_month, etc.)
- Quarter manipulation (next_quarter, to_quarter, etc.)
- Year manipulation (next_year, to_year, etc.)
- Timezone manipulation (tz_localize, tz_convert, etc.)
- Frequency manipulation (round, ceil, floor, etc.)
- Delta adjustment (Equivalent to adding
relativedelta
andpandas.DateOffset
) - Replace adjustment (Equivalent to
datetime.replace
and custompandas.Series.replace
)
Installation
Install from PyPi
pip install cytimes
Install from github
pip install git+https://github.com/AresJef/cyTimes.git
Compatibility
Only support for python 3.10 and above.
Usage (pydt)
import datetime, numpy as np, pandas as pd
from cytimes import pydt
# Parse time string
pt = pydt('2021-01-01 00:00:00')
# 2021-01-01T00:00:00
pt = pydt("2021 Jan 1 11:11 AM")
# 2021-01-01T11:11:00
# dateimte/date/time
pt = pydt(datetime.datetime(2021, 1, 1, 0, 0, 0))
# 2021-01-01T00:00:00
pt = pydt(datetime.date(2021, 1, 1))
# 2021-01-01T00:00:00
pt = pydt(datetime.time(12, 0, 0)) # date defaults to today. Can change through default arugment.
# 2023-09-01T12:00:00
# pandas.Timestamp
pt = pydt(pd.Timestamp("2021-01-01 00:00:00"))
# 2021-01-01T00:00:00
# numpy.datetime64
pt = pydt(np.datetime64("2021-01-01 00:00:00"))
# 2021-01-01T00:00:00
# Access in different data types
pt.dt # -> datetime.datetime
pt.date # -> datetime.date
pt.time # -> datetime.time
pt.timetz # -> datetime.time with timezone
pt.ts # -> pandas.Timestamp
pt.dt64 # -> numpy.datetime64
...
# Conversion to int/float
pt.ordinal # -> int
pt.timestamp # -> float
...
# Calender properties
pt.is_leap_year # -> bool
pt.days_bf_year # -> int
pt.days_in_month # -> int
pt.weekday # -> int
pt.isocalendar # -> tuple
# Day manipulation
pt.monday # -> pydt (monday of the week)
pt.tuesday # -> pydt (tuesday of the week)
pt.next_week("monday") # -> pydt (next monday)
pt.to_week(3, "Mon") # -> pydt (three weeks later monday )
...
# Month manipulation
pt.month_lst # -> pydt (last day of the month)
pt.next_month(3) # -> pydt (next month 3rd day)
pt.to_month(3, 31) # -> pydt (three months later last day)
...
# Quarter manipulation
pt.quarter_1st # -> pydt (first day of the quarter)
pt.next_quarter(2, 10) # -> pydt (next quarter 2nd month 10th day)
pt.to_quarter(2, 10, 15) # -> pydt (two quarters later 2nd month 15th day)
...
# Year manipulation
pt.year_lst # -> pydt (last day of the year)
pt.next_year("jan", 1) # -> pydt (next year jan 1st)
pt.to_year(2, "feb", 29) # -> pydt (two years later feb last day)
...
# Timezone manipulation
pt.tz_localize("UTC") # -> pydt (UTC time)
pt.tz_switch(targ_tz="CET", base_tz="UTC") # -> pydt (Setting base timezone to UTC and convert to CET)
...
# Frequency manipulation
pt.round("H") # -> pydt (round to hour)
...
# Delta adjustment
pt.delta(days=1) # -> pydt (add one day)
# Replace adjustment
pt.replace(year=2022) # -> pydt (replace year to 2022)
Usage (pddt)
pddt
accepts list
and pandas.Series
as argument instead of str
/datetime
comparing to pydt
. Properties and methods are similar to pydt
, except pddt
is designed to work with pandas.Series[datetime64]
.
Acknowledgements
cyTimes is based on several open-source repositories.
cyTimes makes modification of the following open-source repositories:
This package created a Cythonized version of dateutil.parser (cyparser) and dateutil.relativedelta (cytimedelta). As a result, these two modules in this package have sacrificed flexibility and readability in exchange for enhancements in performance. All credits go to the original authors and contributors of dateutil.
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 Distributions
Hashes for cytimes-0.1.12.7-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 52a8e0e21f25f9c2d5cb4b928d3f180d12cdfdee0ce262326448a6758c8ed14a |
|
MD5 | feeb1e7e312d1ed92808c2449c31615f |
|
BLAKE2b-256 | a7fe56af09a70d6ec42a9b8bba6d7db6de1d46c9896bb49055e39c0da2feb34e |
Hashes for cytimes-0.1.12.7-cp312-cp312-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 455c610068db99e538e734e47c932e5cc0277ce118466b7d61e1ee0e75edc97a |
|
MD5 | 01244e14e67e04ce740b0fa01a03e4ed |
|
BLAKE2b-256 | d3a9cbd384453de83f029cc2e71104fe72c936e33880701a680469e4c8e82293 |
Hashes for cytimes-0.1.12.7-cp312-cp312-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1774f972bc93d6ed638eca3d373f4cc401ad951d4ed53121329bc1a4a6828b9c |
|
MD5 | e0321cec89abd966a20bdd0af07966e8 |
|
BLAKE2b-256 | be3b484c7915f8aab4fdd4293d8d66ca4b136d6a1f0ade17fb567f8c6ce646bf |
Hashes for cytimes-0.1.12.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa2b218f34509f61823b56639464eb6182c963c31ff7355a20e5cb342e28e96a |
|
MD5 | cbd37da461fde98979f36f56d5e59cc6 |
|
BLAKE2b-256 | d5712ca01fe997ff35258d71a390d050e2c6a06fd4e46b0d801094feccd00cb9 |
Hashes for cytimes-0.1.12.7-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a7c213d50ee712aa391f97fa1871652fe03b326176b1f9a242d771f95ff91b8 |
|
MD5 | e9e38c0e7a0d1e4bf0368284a2f051e2 |
|
BLAKE2b-256 | 16d1a0aec892005074dbdf2d4f3263518eb25ca2465a79eeb1f5786c0959d6ed |
Hashes for cytimes-0.1.12.7-cp312-cp312-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d1e7f001b83c1eb87d51820d469cde416a817793f9064d5fedd3db88b5f79be2 |
|
MD5 | 56cb66b1c37a01a43e9bc26395468733 |
|
BLAKE2b-256 | d4df70dff24943c0b2532426ba63953cb5db510020762024a3a6691606808b63 |
Hashes for cytimes-0.1.12.7-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f8136743f31ce31267ca3d90cc04b8dd50d9c2d464242104b82c37dc358799d |
|
MD5 | 26047fa5df5c0bbde9596ce23c20a61c |
|
BLAKE2b-256 | c41d74debbeff0f895031cb640ca039062f433a1f826627baa95dd97166b76dc |
Hashes for cytimes-0.1.12.7-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e4a06696c613720fb2cf61f22ef85e5787bef859491f3c2cecf659fa60c89ae |
|
MD5 | 26d79d4f2123d7ded58a85d0c0efb3f9 |
|
BLAKE2b-256 | 3b50bad371368bcdffa787b126363df5eb85c11ef2f68f55a2547aad2d1ddaf9 |
Hashes for cytimes-0.1.12.7-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 687c33a431214ac0d89be4a00bda27222d8fb8a78cea2b4261a049cab151e8ef |
|
MD5 | cf2f902fcc35600c8a66629512f9840f |
|
BLAKE2b-256 | c1dfe8fa3a701ac41d2c5c22d30bf8285c4489b470885ad59a371a5b0b33aa58 |
Hashes for cytimes-0.1.12.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7b3feadb9d3622b17876a9120f0b2a66542458acb439808c682c4d202cd49c52 |
|
MD5 | 51fc4fa60921403dc8f002367de732e8 |
|
BLAKE2b-256 | 1442032536f2ae0b98a1ea417dab85a63a5a08c827daf6c2ed6ac9ebf7b5cd6b |
Hashes for cytimes-0.1.12.7-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c9c065255c1a007ecaf62e9c4537d8fc7161e522bddb56761266eee6a093c924 |
|
MD5 | d50a071a27cc5df2506df9ada052e4a1 |
|
BLAKE2b-256 | e0ffbcca97981d4cc8591c177cd8c7fcdedf466449ef43d12bb984dfc3a3eda7 |
Hashes for cytimes-0.1.12.7-cp311-cp311-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b1d05d507cc021e4ca2971a9685846f64f095785027a1bfc3a35c63721cff839 |
|
MD5 | 256c476869bc4abc1b0e8114f98e8e7e |
|
BLAKE2b-256 | 4ba4e1e909a432243d53a89e4387444a99149d6d9156f5b2becf88868c87808e |
Hashes for cytimes-0.1.12.7-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b4f28b478b8d2d72f4a78d4a0f1b39235a5dfa088f798ab2a4a120c97f751ad4 |
|
MD5 | 197606b76b2c60738990f81911cba492 |
|
BLAKE2b-256 | 11601faec89a55eee12522300b49f6130158e9bc2505d0a7967051b46865d674 |
Hashes for cytimes-0.1.12.7-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 62ed22369bbe1096ea7e33c64fc038575330b4ce4d9ad3ac7de5149631e8cbdc |
|
MD5 | 567ed95fbea9227395c705ae3183ab8b |
|
BLAKE2b-256 | acb06f107bd159c203c265d59af5129317b59d1975f934b9fe22927b290f656b |
Hashes for cytimes-0.1.12.7-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a61b58b49f093a8c0a0a1464b997e0755e8b21499025f52ed6dd25609181840 |
|
MD5 | 9bbf881b1a8b67c395baebe823f982c3 |
|
BLAKE2b-256 | df0cc8ab01594965f717b92a8a3db55180b7bc6d75b75b7dc3df60d97a00d016 |
Hashes for cytimes-0.1.12.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 00d441552d9d07fc40700592be829aeab97651e79104824e12a19ea37415c138 |
|
MD5 | fb9740fa514ece7e5cecf8b5b5b4a70b |
|
BLAKE2b-256 | f7cb58422769658457d1fdfe3803c60efb93abe1acac5c23887d56c62011445b |
Hashes for cytimes-0.1.12.7-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1099a7124f745153e5e47266a8d34d469d347770a4ff6c0292a6fd6264482db6 |
|
MD5 | 3f9dffaac3f606d090e6daf260a2ca2a |
|
BLAKE2b-256 | 37589a0b9b04826537882f4f3e974c3d3d9bd41667fc22a4cbc4166b0d059716 |
Hashes for cytimes-0.1.12.7-cp310-cp310-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 48a077e64b5e36b15506e563bae98bbf9aac540337a30cbb81ac895d976c1b5e |
|
MD5 | 3eb934d9bb8238ecec355393d3f3c7fc |
|
BLAKE2b-256 | d4ff4aad170a711c7701561028b11ba168260f01515a0db2af6caf11dbd47353 |