count() in Time Series Aggregate Mode - Teradata Python Package

Teradata® Python Package User Guide

Product
Teradata Python Package
Release Number
16.20
Published
February 2020
Language
English (United States)
Last Update
2020-02-29
dita:mapPath
rkb1531260709148.ditamap
dita:ditavalPath
Generic_no_ie_no_tempfilter.ditaval
dita:id
B700-4006
lifecycle
previous
Product Category
Teradata Vantage

The count() function returns column-wise count of the DataFrame.

Example here is only for count() as Time Series Aggregate function. For count() as regular aggregate, refer to count() in Regular Aggregate Mode.

Examples Prerequisite

Load the example datasets:
>>> load_example_data("dataframe", ["ocean_buoys", "ocean_buoys_seq", "ocean_buoys_nonpti"])

Example: Run count() on DataFrame created on sequenced PTI table

>>> ocean_buoys_seq = DataFrame("ocean_buoys_seq")
>>> ocean_buoys_seq.columns
['TD_TIMECODE', 'TD_SEQNO', 'buoyid', 'salinity', 'temperature', 'dates']
>>> ocean_buoys_seq
                       TD_TIMECODE  TD_SEQNO  salinity  temperature       dates
buoyid
44      2014-01-06 10:00:25.122200         6        55           43  2014-06-06
44      2014-01-06 10:01:25.122200         8        55           53  2014-08-08
44      2014-01-06 10:01:25.122200        20        55           54  2015-08-20
1       2014-01-06 09:01:25.122200        11        55           70  2014-11-11
1       2014-01-06 09:02:25.122200        12        55           71  2014-12-12
1       2014-01-06 09:02:25.122200        24        55           78  2015-12-24
1       2014-01-06 09:03:25.122200        13        55           72  2015-01-13
1       2014-01-06 09:03:25.122200        25        55           79  2016-01-25
1       2014-01-06 09:01:25.122200        23        55           77  2015-11-23
44      2014-01-06 10:00:26.122200         7        55           43  2014-07-07
>>> ocean_buoys_grpby1 = ocean_buoys_seq.groupby_time(timebucket_duration="2cy", value_expression="buoyid", fill="NULLS")
>>> ocean_buoys_grpby1.count().sort(["TIMECODE_RANGE", "buoyid"])
                                      TIMECODE_RANGE  GROUP BY TIME(CAL_YEARS(2))  buoyid  count_TD_TIMECODE  count_TD_SEQNO  count_salinity  count_temperature  count_dates
0  ('2014-01-01 00:00:00.000000-00:00', '2016-01-...                            2       0                  5               5               5                  4            5
1  ('2014-01-01 00:00:00.000000-00:00', '2016-01-...                            2       1                  6               6               6                  6            6
2  ('2014-01-01 00:00:00.000000-00:00', '2016-01-...                            2       2                  3               3               3                  3            3
3  ('2014-01-01 00:00:00.000000-00:00', '2016-01-...                            2      22                  1               1               1                  1            1
4  ('2014-01-01 00:00:00.000000-00:00', '2016-01-...                            2      44                 13              13              13                 13           13