| |
Methods defined here:
- __init__(self, data=None, target_columns=None, include_first=False, window_size=10, data_sequence_column=None, data_partition_column=None, data_order_column=None)
- DESCRIPTION:
The WeightedMovAvg function computes the weighted moving average the average of
points in a time series, applying weights to older values. The
weights for the older values decrease arithmetically.
PARAMETERS:
data:
Required Argument.
Specifies the name of the teradataml DataFrame that contains the
columns.
data_partition_column:
Required Argument.
Specifies Partition By columns for data.
Values to this argument can be provided as list, if multiple columns
are used for partition.
Types: str OR list of Strings (str)
data_order_column:
Required Argument.
Specifies Order By columns for data.
Values to this argument can be provided as list, if multiple columns
are used for ordering.
Types: str OR list of Strings (str)
target_columns:
Optional Argument.
Specifies the input column names for which the moving average is to
be computed. If you omit this argument, then the function copies
every input column to the output teradataml DataFrame but does not
compute moving average.
Types: str OR list of Strings (str)
include_first:
Optional Argument.
Specifies whether to include the starting rows in the output table.
If you specify "true", the output columns for the starting rows
contain NULL, because their exponential moving average is undefined.
Default Value: False
Types: bool
window_size:
Optional Argument.
Specifies the number of old values to be considered for calculating
the new weighted moving average.
Default Value: 10
Types: int
data_sequence_column:
Optional Argument.
Specifies the list of column(s) that uniquely identifies each row of
the input argument "data". The argument is used to ensure
deterministic results for functions which produce results that vary
from run to run.
Types: str OR list of Strings (str)
RETURNS:
Instance of WeightedMovAvg.
Output teradataml DataFrames can be accessed using attribute
references, such as WeightedMovAvgObj.<attribute_name>.
Output teradataml DataFrame attribute name is:
result
RAISES:
TeradataMlException
EXAMPLES:
# Load Example Data
load_example_data("weightedmovavg", "stock_vol")
# Create teradataml DataFrame objects.
stock_vol = DataFrame.from_table("stock_vol")
# Example: Compute the weighted moving average for columns: "stockprice" and "volume".
# The input table, stock_vol, contains hypothetical stock price and volume data of three
# companies between 17 May 1961 and 21 June 1961.
WeightedMovAvg_out = WeightedMovAvg(data = stock_vol,
data_partition_column = ["id"],
data_order_column = ["name"],
target_columns = ["stockprice","volume"],
include_first = True,
window_size = 5
)
# Print the results
print(WeightedMovAvg_out)
- __repr__(self)
- Returns the string representation for a WeightedMovAvg class instance.
|