verticapy.vDataFrame.product#
- vDataFrame.product(columns: str | list[str] | None = None, **agg_kwargs) TableSample #
Aggregates the vDataFrame by applying the
product
aggregation function. This function computes the product of values within the dataset, providing insights into the multiplication of data points.The
product
aggregation can be particularly useful when we need to assess cumulative effects or when multiplying values is a key aspect of the analysis. This operation can be relevant in various domains, such as finance, economics, and engineering, where understanding the combined impact of values is critical for decision-making and modeling.Note
Since
product
is not a conventional SQL aggregation, we employ a unique approach by combining the sum of logarithms and the exponential function for its computation. This non-standard methodology is utilized to derive the product of values within the dataset, offering a distinctive way to understand the multiplicative effects of data points.Parameters#
- columns: SQLColumns, optional
List of the vDataColumn names. If empty, all numerical vDataColumns are used.
- **agg_kwargs
Any optional parameter to pass to the Aggregate function.
Returns#
- TableSample
result.
Examples#
For this example, we will use the following dataset:
import verticapy as vp data = vp.vDataFrame( { "x": [1, 2, 4, 9, 10, 15, 20, 22], "y": [1, 2, 1, 2, 1, 1, 2, 1], "z": [10, 12, 2, 1, 9, 8, 1, 3], } )
Now, let’s calculate the product for specific columns.
data.product( columns = ["x", "y", "z"], )
prod "x" 4752000.0 "y" 8.0 "z" 51840.0 Note
All the calculations are pushed to the database.
Hint
For more precise control, please refer to the
aggregate
method.See also
vDataFrame.
aggregate()
: Aggregates for particular columns.vDataFrame.
quantile()
: Quantile Aggregates for particular columns.