tfp.substrates.numpy.sts.regularize_series
Stay organized with collections
Save and categorize content based on your preferences.
Infers frequency and makes an irregular time series regular.
tfp.substrates.numpy.sts.regularize_series(
series,
frequency=None,
warn_missing_tolerance=None,
err_missing_tolerance=None,
max_series_length=None
)
Converts a time series into a regular time series having the same
period between successive time points (e.g. 5 seconds, or 1 day). If
the frequency is known, it can be supplied through the 'frequency'
argument; otherwise it will be inferred.
If multiple values share the same timestamp, they are summed into a single
value.
Args |
series
|
a Pandas pd.Series instance indexed by a pd.DateTimeIndex . This
may also be a single-column pd.DataFrame .
|
frequency
|
a Pandas DateOffset object, e.g. pd.DateOffset(seconds=1) . If
no frequency is specified, and the index of series does not have a
frequency populated, the granularity of the time series will be inferred
automatically.
Default value: None .
|
warn_missing_tolerance
|
optional instance of
tfp.sts.MissingValuesTolerance , specifying warning thresholds for
too many missing values.
Default value: None . (do not warn).
|
err_missing_tolerance
|
optional instance of
tfp.sts.MissingValuesTolerance , specifying error thresholds for
too many missing values.
Default value: None . (do not raise errors).
|
max_series_length
|
int maximum length of the regularized
series (note that regularization may increase the length of the series).
Used to bound the resources used per invocation.
Default value: None .
|
Returns |
regularized_series
|
instance of the same type as series
(pd.Series or pd.DataFrame ) whose index follows a regular
frequency (regularized_series.index.freq is not None ). Any values
not provided are filled in as NaN .
|
Raises |
TypeError
|
if data is not an instance of pd.Series or pd.DataFrame .
|
ValueError
|
if data is empty, data.index is not a DatetimeIndex,
data.index is not sorted, or if applying the inferred
frequency would exceed the max_series_length or create
more missing values than allowed by err_missing_vals .
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-11-21 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2023-11-21 UTC."],[],[],null,["# tfp.substrates.numpy.sts.regularize_series\n\n\u003cbr /\u003e\n\n|--------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/probability/blob/v0.23.0/tensorflow_probability/substrates/numpy/sts/regularization.py#L49-L137) |\n\nInfers frequency and makes an irregular time series regular.\n\n#### View aliases\n\n\n**Main aliases**\n\n[`tfp.experimental.substrates.numpy.sts.regularize_series`](https://www.tensorflow.org/probability/api_docs/python/tfp/substrates/numpy/sts/regularize_series)\n\n\u003cbr /\u003e\n\n tfp.substrates.numpy.sts.regularize_series(\n series,\n frequency=None,\n warn_missing_tolerance=None,\n err_missing_tolerance=None,\n max_series_length=None\n )\n\nConverts a time series into a regular time series having the same\nperiod between successive time points (e.g. 5 seconds, or 1 day). If\nthe frequency is known, it can be supplied through the 'frequency'\nargument; otherwise it will be inferred.\n\nIf multiple values share the same timestamp, they are summed into a single\nvalue.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|--------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `series` | a Pandas `pd.Series` instance indexed by a `pd.DateTimeIndex`. This may also be a single-column `pd.DataFrame`. |\n| `frequency` | a Pandas DateOffset object, e.g. `pd.DateOffset(seconds=1)`. If no frequency is specified, and the index of `series` does not have a frequency populated, the granularity of the time series will be inferred automatically. Default value: `None`. |\n| `warn_missing_tolerance` | optional instance of [`tfp.sts.MissingValuesTolerance`](../../../../tfp/sts/MissingValuesTolerance), specifying warning thresholds for too many missing values. Default value: `None`. (do not warn). |\n| `err_missing_tolerance` | optional instance of [`tfp.sts.MissingValuesTolerance`](../../../../tfp/sts/MissingValuesTolerance), specifying error thresholds for too many missing values. Default value: `None`. (do not raise errors). |\n| `max_series_length` | `int` maximum length of the regularized series (note that regularization may increase the length of the series). Used to bound the resources used per invocation. Default value: `None`. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|----------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `regularized_series` | instance of the same type as `series` (`pd.Series` or `pd.DataFrame`) whose index follows a regular frequency (`regularized_series.index.freq is not None`). Any values not provided are filled in as `NaN`. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|--------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `TypeError` | if `data` is not an instance of `pd.Series` or `pd.DataFrame`. |\n| `ValueError` | if `data` is empty, `data.index` is not a DatetimeIndex, `data.index` is not sorted, or if applying the inferred frequency would exceed the `max_series_length` or create more missing values than allowed by `err_missing_vals`. |\n\n\u003cbr /\u003e"]]