cube() | DataFrame Manipulation | Teradata Package for Python - cube() Function - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
Language
English (United States)
Last Update
2024-04-03
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

Use the cube() function to create a multidimensional cube for a teradataml DataFrame using specified columns, and there by running aggregates on it produce the aggregations on different dimensions.

Required Argument:
  • columns: Specifies the names of input teradataml DataFrame columns.

Example Setup

In this example, "admission_train" dataset is used.

>>> from teradataml import *
>>> load_example_data("dataframe", "admissions_train")
>>> df = DataFrame("admissions_train")

Example 1: Analyzes the data by grouping into masters and stats dimensions

>>> df1 = df.cube(["masters", "stats"]).sum()
>>> df1
  masters     stats  sum_id  sum_gpa  sum_admitted
0      no  Beginner       8     3.60             1
1    None  Advanced     555    84.21            16
2    None  Beginner      21    18.31             3
3     yes  Beginner      13    14.71             2
4    None      None     820   141.67            26
5     yes  Advanced     366    49.26             7
6      no      None     343    63.96            16
7    None    Novice     244    39.15             7
8      no  Advanced     189    34.95             9
9     yes    Novice      98    13.74             1