Teradata Package for Python Function Reference | 20.00 - max - Teradata Package for Python - Look here for syntax, methods and examples for the functions included in the Teradata Package for Python.
Teradata® Package for Python Function Reference - 20.00
- Deployment
- VantageCloud
- VantageCore
- Edition
- Enterprise
- IntelliFlex
- VMware
- Product
- Teradata Package for Python
- Release Number
- 20.00.00.03
- Published
- December 2024
- ft:locale
- en-US
- ft:lastEdition
- 2024-12-19
- dita:id
- TeradataPython_FxRef_Enterprise_2000
- Product Category
- Teradata Vantage
- teradataml.dataframe.dataframe.DataFrameGroupByTime.max = max(self, distinct=False)
- DESCRIPTION:
Returns column-wise maximum value of the dataframe.
Note:
Null values are not included in the result computation.
PARAMETERS:
distinct:
Optional Argument.
Specifies whether to exclude duplicate values while calculating the maximum value.
Default Values: False
Types: bool
RETURNS:
teradataml DataFrame object with max()
operation performed.
RAISES:
TeradataMLException
1. EXECUTION_FAILED - If max() operation fails to
generate the column-wise maximum value of the dataframe.
Possible error message:
Failed to perform 'max'. (Followed by error message)
2. TDMLDF_AGGREGATE_COMBINED_ERR - If the max() operation
doesn't support all the columns in the dataframe.
Possible error message:
No results. Below is/are the error message(s):
All selected columns [(col2 - PERIOD_TIME), (col3 -
BLOB)] is/are unsupported for 'max' operation.
EXAMPLES :
# Load the data to run the example.
>>> from teradataml.data.load_example_data import load_example_data
>>> load_example_data("dataframe", ["employee_info"])
# Create teradataml dataframe.
>>> df1 = DataFrame("employee_info")
>>> print(df1)
first_name marks dob joined_date
employee_no
101 abcde None None 02/12/05
100 abcd None None None
112 None None None 18/12/05
>>>
# Prints maximum value of each column(with supported data types).
>>> df1.max()
max_employee_no max_first_name max_marks max_dob max_joined_date
0 112 abcde None None 18/12/05
>>>
# Select only subset of columns from the DataFrame.
>>> df3 = df1.select(['employee_no', 'first_name', 'joined_date'])
# Prints maximum value of each column(with supported data types).
>>> df3.max()
max_employee_no max_first_name max_joined_date
0 112 abcde 18/12/05
>>>
#
# Using max() as Time Series Aggregate.
#
>>> # Load the example datasets.
... load_example_data("dataframe", ["ocean_buoys"])
>>>
>>> # Create the required DataFrames.
... # DataFrame on non-sequenced PTI table
... ocean_buoys = DataFrame("ocean_buoys")
>>> # Check DataFrame columns and let's peek at the data
... ocean_buoys.columns
['buoyid', 'TD_TIMECODE', 'temperature', 'salinity']
>>> ocean_buoys.head()
TD_TIMECODE temperature salinity
buoyid
0 2014-01-06 08:10:00.000000 100.0 55
0 2014-01-06 08:08:59.999999 NaN 55
1 2014-01-06 09:01:25.122200 77.0 55
1 2014-01-06 09:03:25.122200 79.0 55
1 2014-01-06 09:01:25.122200 70.0 55
1 2014-01-06 09:02:25.122200 71.0 55
1 2014-01-06 09:03:25.122200 72.0 55
0 2014-01-06 08:09:59.999999 99.0 55
0 2014-01-06 08:00:00.000000 10.0 55
0 2014-01-06 08:10:00.000000 10.0 55
#
# Time Series Aggregate Example 1: Executing max() function on DataFrame created on
# non-sequenced PTI table. We will consider all rows for the
# columns while calculating the maximum values.
#
# To use max() as Time Series Aggregate we must run groupby_time() first, followed by max().
>>> ocean_buoys_grpby1 = ocean_buoys.groupby_time(timebucket_duration="2cy",
... value_expression="buoyid", fill="NULLS")
>>> ocean_buoys_grpby1.max().sort(["TIMECODE_RANGE", "buoyid"])
TIMECODE_RANGE GROUP BY TIME(CAL_YEARS(2)) buoyid max_TD_TIMECODE max_salinity max_temperature
0 ('2014-01-01 00:00:00.000000-00:00', '2016-01-... 2 0 2014-01-06 08:10:00.000000 55 100
1 ('2014-01-01 00:00:00.000000-00:00', '2016-01-... 2 1 2014-01-06 09:03:25.122200 55 79
2 ('2014-01-01 00:00:00.000000-00:00', '2016-01-... 2 2 2014-01-06 21:03:25.122200 55 82
3 ('2014-01-01 00:00:00.000000-00:00', '2016-01-... 2 44 2014-01-06 10:52:00.000009 55 56
>>>
#
# Time Series Aggregate Example 2: Executing max() function on DataFrame created on
# non-sequenced PTI table. We will consider DISTINCT values for the
# columns while calculating the maximum value.
#
# To use max() as Time Series Aggregate we must run groupby_time() first, followed by max().
>>> ocean_buoys_grpby1 = ocean_buoys.groupby_time(timebucket_duration="2cy",
... value_expression="buoyid", fill="NULLS")
>>> ocean_buoys_grpby1.max(distinct = True).sort(["TIMECODE_RANGE", "buoyid"])
TIMECODE_RANGE GROUP BY TIME(CAL_YEARS(2)) buoyid max_TD_TIMECODE max_salinity max_temperature
0 ('2014-01-01 00:00:00.000000-00:00', '2016-01-... 2 0 2014-01-06 08:10:00.000000 55 100
1 ('2014-01-01 00:00:00.000000-00:00', '2016-01-... 2 1 2014-01-06 09:03:25.122200 55 79
2 ('2014-01-01 00:00:00.000000-00:00', '2016-01-... 2 2 2014-01-06 21:03:25.122200 55 82
3 ('2014-01-01 00:00:00.000000-00:00', '2016-01-... 2 44 2014-01-06 10:52:00.000009 55 56
>>>