Advice for Merging Tag History Query Data - Error adding column to dataset (addColumn, columnAsList, 2nd arg can't be coerced to org.python.core.PySequence)

In a session prop change script I perform a series of system.tag.queryTagCalculations() and system.tag.queryTagHistory() operations. I then want to assemble these returns as a single dataset for a table. In reference to the pseduo-code below, I'm getting a type error when passing the return from data.getColumnAsList(colIndex) into system.dataset.addColumn().

paths = sessionProp.paths
names = sessionProp.names
calcs = ['Count']

timeRange = -30
data1 = system.tag.queryTagCalculations(paths=paths, calculations=calcs, aliases=names, rangeMinutes=timeRange)
timeRange= -1
data2 = system.tag.queryTagCalculations(paths=paths, calculations=calcs, aliases=names, rangeHours=timeRange)

output = system.dataset.addColumn(data1, data2.getColumnAsList(1), 'Last Hour', int)
# throws error: `TypeError: addColumn(): 2nd arg can't be coerced to org.python.core.PySequence`

I currently switched to a method like this, that is working:

columns = ['Tag Names', 'Data1 Column Name', 'Data2 Column Name', ... 'Data6 Column Name']
rows = []
for row in range(data1.getRowCount()):
    c0 = data1.getValueAt(row, 0)   # tag names
    c1 = data1.getValueAt(row, 1)
    c2 = data2.getValueAt(row, 1)
    c3 = data3.getValueAt(row, 1)
    c7 = data2.getValueAt(row, 1)
    rows.append([c0, c1, c2, c3, c4, c5, c6])
system.dataset.toDataSet(rows, columns)

I am just wondered if this is appropriate and what impact it may have on performance. Other tables I will be assembling will have 15 columns, and will be updated every second. Is there a better way to use the tag history system to collate various queries into a single table? There will be both 'live' tables and historical tables, and as far as I can tell the data in each column require unique parameters for their tag history query (different start and end times, different aggregation modes, and some using interval time slices while others look at the entire window).

At this time I cannot modify the PLC to produce data in the same way I need to retrieve it. As for setting up transaction groups, I would like to leverage tag UDT definitions and at this time I believe I can only configure tag history there and not transaction groups.

Hi Bill_DiBlasi,

Manipulating dataset is complicated. To change a dataset, you really create a new one and then copy over the data from the old dataset with the new changes. This can cause performance issue if you make changes to large dataset or at a fast rate. Datasets - Ignition User Manual 8.1 - Ignition Documentation. I would suggest to contact Inductive Automation Support for more specific help on this.

Thank you @Emma_Ngo!

Ultimately, I was able to gain access to the PLC for editing. I developed SCADA interface code that supplies the data in the way I wish to retrieve it from the database. I also added PLC tags to directly handle some live-data requirements. This allowed me to reduce the size of my Tag History queries, and eliminated the need to do any extra data processing after retrieval from the database.