Saving individual column to tags

So I have a data table with four columns and I’m trying to take 2 of those columns (column 0 and 3) and save them to a data set tag

I’m having a little trouble working around a coding error. in the second to last line.

data = event.source.parent.getComponent("Table").data
pds = system.dataset.toPyDataSet(data)

Date_data = [col[0] for row in pds]
GDD_data = [row[3] for row in pds]	


headers = ["Date", "GDD"]
New_data = [Date_data, GDD_data]

tagdata = system.dataset.toDataSet(headers, New_data)
system.tag.write("Growing Days", tagdata)

error: Row 0 doesn’t have the same number of columns as header list.

Try this:

data = event.source.parent.getComponent("Table").data
pds = system.dataset.toPyDataSet(data)

#Date_data = [col[0] for row in pds]  #Removed, see below
#GDD_data = [row[3] for row in pds]  #Removed, see below

headers = ["Date", "GDD"]
New_data = [[col[0], row[3]] for row in pds]

tagdata = system.dataset.toDataSet(headers, New_data)
system.tag.write("Growing Days", tagdata)

toDataSet() takes a list of lists, so New_data has to assign it like this.

Super helpful. Much Thanks! :pray: