current_utc
| Type | Description |
|---|---|
datetime | Current time in UTC as a datetime object. |
current_utc_str
| Type | Description |
|---|---|
str | Current time in UTC as a string in the format %Y-%m-%dT%H:%M:%S. |
to_offset
pd.DateOffset.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
freq | str, int, Offset, or pd.Timedelta | -- | The frequency-like object to convert. |
| Type | Description |
|---|---|
Offset | The converted frequency as a pd.DateOffset. |
to_timedelta
| Name | Type | Default | Description |
|---|---|---|---|
freq | str, int, Offset, pd.Timedelta | -- | The frequency-like object to be converted. |
approximate | bool | False | If True, approximate the frequency using _offset_to_timedelta. |
| Type | Description |
|---|---|
pd.Timedelta | The corresponding timedelta. |
to_timedelta64
| Name | Type | Default | Description |
|---|---|---|---|
freq | str, int, Offset, pd.Timedelta | -- | The frequency-like object to be converted. |
| Type | Description |
|---|---|
np.timedelta64 | The corresponding numpy timedelta64. |
time_to_timedelta
pd.Timedelta.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
t | str, time, FreqHandler | -- | The time-like object to be converted. |
kwargs | tp.Kwargs | -- | Additional arguments passed to FreqHandler.parse_time_str if t is a string. |
| Type | Description |
|---|---|
ValueError | If the time string has a date or weekday component, or lacks a time component. |
| Type | Description |
|---|---|
pd.Timedelta | The resulting pd.Timedelta. |
to_timestamp
pd.Timestamp.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
dt | str, int, pd.Timestamp | -- | The datetime-like object to be parsed. |
parse_with_dateparser | bool | True | If True, use dateparser to parse string inputs. |
dateparser_kwargs | dict | None | Additional arguments passed to dateparser.parse. |
unit | str | ns | The unit of the input when dt is a number. |
kwargs | tp.Kwargs | -- | Additional arguments passed to pd.Timestamp. |
| Type | Description |
|---|---|
ValueError | If the input cannot be parsed as a pd.Timestamp. |
| Type | Description |
|---|---|
pd.Timestamp | The parsed pd.Timestamp. |
<Note> | This function supports various datetime-like inputs and attempts to parse them into a pd.Timestamp. If the input is a string, both Pandas and dateparser (if enabled) will be used for parsing. The tz argument allows specifying the desired time zone for the output. |
</Note> |
to_datetime
datetime.datetime.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
dt | str, int, pd.Timestamp | -- | The datetime-like object to be parsed. |
kwargs | tp.Kwargs | -- | Additional arguments passed to to_timestamp. |
| Type | Description |
|---|---|
datetime.datetime | The parsed datetime.datetime object. |
to_freq
| Name | Type | Default | Description |
|---|---|---|---|
freq | str, int, Offset, pd.Timedelta | -- | The frequency-like object to be converted. |
allow_offset | bool | True | If True, allow conversion to pandas DateOffset. |
keep_offset | bool | False | If True, keep the original DateOffset if applicable. |
| Type | Description |
|---|---|
Offset or pd.Timedelta | The corresponding DateOffset or Timedelta. |
date_range
| Name | Type | Default | Description |
|---|---|---|---|
start | str | None | The start time for the date range. |
end | str | None | The end time for the date range. |
periods | int | None | Number of periods to generate. |
freq | str | None | Frequency string or frequency object. |
tz | str | None | Time zone for the resulting DatetimeIndex. |
inclusive | str | left | Include boundaries; left, right, both, or neither. |
timestamp_kwargs | tp.Kwargs | None | Additional arguments passed to to_timestamp. |
freq_kwargs | tp.Kwargs | None | Additional arguments passed to to_freq. |
kwargs | tp.Kwargs | -- | Additional arguments passed to pd.date_range. |
| Type | Description |
|---|---|
pd.DatetimeIndex | A fixed frequency DatetimeIndex. |
<Note> | |
This function preprocesses startandendwithto_timestamp, freq“ | |
with to_freq, and tzwithto_timezone. | |
If startandperiodsare None,start is set to the beginning of the | |
Unix epoch. Similarly, if endandperiodsare None,end is set to the | |
current date and time. | |
</Note> |
prepare_dt_index
| Name | Type | Default | Description |
|---|---|---|---|
index | range | -- | or sequence of any The index to be converted to a datetime index. |
parse_index | bool | True | If True, attempts to parse the index using Pandas and dateparser. Default is True. |
parse_with_dateparser | bool | True | If True, uses dateparser for parsing in addition to Pandas. Default is True. |
dateparser_kwargs | dict | None | Arguments to pass to dateparser.parse. Default is None. |
kwargs | tp.Kwargs | -- | Additional arguments to pass to pd.to_datetime. |
| Type | Description |
|---|---|
pd.Index | The converted datetime index. |
| Type | Description |
|---|---|
Exception | If parsing fails and parse_index and parse_with_dateparser are both True. |
<Note> | |
“dateparser_kwargsare passed todateparser.parsewhile**kwargs are | |
passed to pd.to_datetime. | |
</Note> |
try_align_to_dt_index
| Name | Type | Default | Description |
|---|---|---|---|
source_index | pd.Index | -- | The source index to be aligned. |
target_index | pd.Index | -- | The target datetime index to align to. |
kwargs | tp.Kwargs | -- | Additional arguments passed to prepare_dt_index. |
| Type | Description |
|---|---|
pd.Index | The aligned datetime index. |
<Note> | |
Keyword arguments are passed to prepare_dt_index. | |
</Note> |
try_align_dt_to_index
| Name | Type | Default | Description |
|---|---|---|---|
dt | str, int, or pd.Timestamp | -- | The datetime-like object to align. |
target_index | pd.Index | -- | The target datetime index to align to. |
kwargs | tp.Kwargs | -- | Additional arguments passed to to_timestamp. |
| Type | Description |
|---|---|
str, int, or pd.Timestamp | The aligned datetime-like object. |
<Note> | |
Keyword arguments are passed to to_timestamp. | |
</Note> |
auto_detect_freq
| Name | Type | Default | Description |
|---|---|---|---|
index | pd.Index | -- | The datetime index from which to detect frequency. |
| Type | Description |
|---|---|
Offset or pd.Timedelta | The detected frequency. |
<Note> | |
Returns the minimal frequency if it is encountered in most of the index. | |
</Note> |
parse_index_freq
| Name | Type | Default | Description |
|---|---|---|---|
index | pd.DatetimeIndex | -- | The datetime index from which to parse frequency. |
| Type | Description |
|---|---|
Offset or pd.Timedelta | The parsed frequency. |
infer_index_freq
freq is None, otherwise convert to
the required frequency.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
index | pd.Index | -- | The index from which to infer frequency. |
freq | str | None | The frequency to be used or converted. If None, the frequency is inferred from the index. If auto, the frequency is automatically detected. If index_[method_name], the method is applied to the pd.TimedeltaIndex derived from the differences between each pair of index points. |
allow_offset | bool | True | If True, allows the output frequency to be a Offset instance. |
allow_numeric | bool | True | If True, allows the output frequency to be a numeric value (int or float). |
freq_from_n | int | 20 | If an int, limits the index to the first or last N index points respectively for frequency inference. If None, the entire index is considered. If a boolean, raises a ValueError if True. |
| Type | Description |
|---|---|
ValueError | If freq_from_n is True. |
| Type | Description |
|---|---|
None, int, float, Offset, pd.Timedelta | The inferred or converted frequency of the index. The type of the return value depends on the input parameters and the inferred frequency. Returns None if the frequency cannot be determined. |
get_ann_factor
| Name | Type | Default | Description |
|---|---|---|---|
freq | pd.Timedelta | -- | Frequency. |
| Type | Description |
|---|---|
float | Annualization factor. |
resolve_dates
| Name | Type | Default | Description |
|---|---|---|---|
start | str | None | The start date. Defaults to None. |
end | str | None | The end date. Defaults to None. |
| Type | Description |
|---|---|
tuple | Start and end dates of the data. |
FreqHandler
| Name | Type | Default | Description |
|---|---|---|---|
year | Optional[int] | None | Year. |
month | Optional[int] | None | Month. |
day | Optional[int] | None | Day of month. |
weekday | Optional[int] | None | Day of week. |
hour | Optional[int] | None | Hour. |
minute | Optional[int] | None | Minute. |
second | Optional[int] | None | Second. |
nanosecond | Optional[int] | None | Nanosecond. |
Static methods
parse_time_str
DTC instance from a time string.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
time_str | str | -- | The time string to parse. |
parse_kwargs | tp.Kwargs | -- | Additional keyword arguments passed to the date parser. |
| Type | Description |
|---|---|
ValueError | If the time string has a date or weekday component, or lacks a time component. |
| Type | Description |
|---|---|
FreqHandler | A FreqHandler instance representing the parsed time. |
Instance variables
-
year: int | None: The type of the None singleton. -
month: int | None: The type of the None singleton. -
day: int | None: The type of the None singleton. -
weekday: int | None: The type of the None singleton. -
hour: int | None: The type of the None singleton. -
minute: int | None: The type of the None singleton. -
second: int | None: The type of the None singleton. -
nanosecond: int | None: The type of the None singleton.
Methods
has_date
| Type | Description |
|---|---|
bool | True if any of year, month, or day is set, False otherwise. |
has_weekday
| Type | Description |
|---|---|
bool | True if weekday is set, False otherwise. |
has_time
| Type | Description |
|---|---|
bool | True if any of hour, minute, second, or nanosecond is set, False otherwise. |
to_time
datetime.time instance.
Returns:
| Type | Description |
|---|---|
time | A datetime.time instance representing the time components. |

