Jump to content
We've recently updated our Privacy Statement, available here. ×
  • How to Add an Unpivot Transformation to a Data Table in Spotfire® Using IronPython Scripting


    This article provides a sample script reference on how to add a Unpivot Transformation to a data table using IronPython scripting

    Introduction

    This article provides a sample script reference on how to add a Unpivot Transformation to a data table using IronPython scripting

    Code Sample

    # Copyright © 2019. TIBCO Software Inc. Licensed under TIBCO BSD-style license.
    
    from Spotfire.Dxp.Data.Transformations import UnpivotTransformation
    from System.Collections.Generic import List
    
    unPivot=UnpivotTransformation()
    
    #Define columns to pass through
    list = List[DataColumnSignature]()
    list.Clear()
    col = table.Columns['AT_BATS']
    list.Add(DataColumnSignature(col))
    unPivot.IdentityColumns = list
    
    #Define columns to transform
    list1 = List[DataColumnSignature]()
    list1.Clear()
    col = table.Columns['ASSISTS']
    list1.Add(DataColumnSignature(col))
    col = table.Columns['NAME']
    list1.Add(DataColumnSignature(col))
    unPivot.ValueColumns = list1
    
    
    #Define category column
    unPivot.CategoryName = "Category";
    unPivot.CategoryType = DataType.String;
    
    #Define result column
    unPivot.ResultName = "Value";
    unPivot.ResultType = DataType.Integer;
    
    # add transformation
    table.AddTransformation(unPivot)
     

    References

    License:  TIBCO BSD-Style License

     

     


    User Feedback

    Recommended Comments

    There are no comments to display.


×
×
  • Create New...