I am executing a data function via ironpython, and the input is predefined (a column from an existing data table). Now I would like to filter this input by applying a filtering scheme to it. How do I do this? I only want to filter the input, not the data table behind it.
Edit: since I can create a copy of the data table, filtering the data table would be fine as well, if there is a way to do that outside of the visualization of the data table.
In your question of September 4 you were setting a filter to act on a data table. This would work the same way. This example should help. It uses the iris dataset and has myDataTable as input of type DataTable.
You first set a filter on the species column, then run a data function called my data function, then reset the filter. The data function needs to be executed synchronously, and be set up to already accept a filtered data table as input.
You can modify it to save the current filter values and reset to them, rather than simply include all values.
import Spotfire.Dxp.Data
import Spotfire.Dxp.Application.Filters
from Spotfire.Dxp.Application.Filters import ListBoxFilter,FilterTypeIdentifiers
from Spotfire.Dxp.Data.DataFunctions import *
# define column to filter on and set filter
colName = "Species"
filter=Document.FilteringSchemes[0][myDataTable][myDataTable.Columns[colName]]
filter.TypeId = FilterTypeIdentifiers.ListBoxFilter
filter = filter.As[ListBoxFilter]()
tofilter = ["setosa", "versicolor"]
filter.IncludeAllValues=False
filter.SetSelection(tofilter)
#run data function synchronously
dataManager = Document.Data
for function in dataManager.DataFunctions:
if function.Name == 'my data function':
function.ExecuteSynchronously()
#reset filter
filter.IncludeAllValues=True