Functional Series Data: How to check whether Serie with the same paramaters already exists

Daniel Manocchio
Daniel Manocchio Member Posts: 24
5 Likes 10 Comments Photogenic
**

Hi Guys,
I'm trying to write a function which checks whether the parameters of series already existing in a FDA attribute are identical to the parameters of new data. This shall happen prior to uploading additional data, in order to unintentionally add series with the same parameters, as STK seems to always append series instead of overwriting them - even if a series with the same parameters already exists.

However, I'm struggling with the data structure of FDA attributes. Especially the fact that the data comes as list of lists from the record, but data to be added has to be prepared as list of dictionaries.

Is there any convinient way to compare the parameter sets without y and x values of series in a record with those of series to be added?

Bests,
Daniel

Best Answer

  • Ludovic Steinbach
    Ludovic Steinbach Member, Employee Posts: 2
    First Comment First Anniversary First Answer
    ✭✭✭
    Answer ✓

    Hi Daniel,

    Thank you for your question.
    The interface for functional data has been designed to help with relatively simple cases, and as you've observed, can be difficult to work with when dealing with multiple series. It is on the development roadmap to improve the interface to make complex use cases more accessible.

    As you've mentioned, you can read exported functional attribute data via FunctionalSeries.value, which returns a list of all the points in the attribute value, where each point is a list that includes the X, Y, and additional parameter values.

    You can also use the FunctionalSeries.data_with_series_number property to obtain a similar list, but with an additional
    column that represents the series number, based on the parameter values. This might help you identify individual series, from which you can then read the parameter values.

    The methods FunctionalSeries.add_point(...) and FunctionalSeries.add_range(...) are not really suitable to add data to an existing series.
    To do so, you can mutate the FunctionalSeries.value list, by inserting new points (as lists of values
    that corresponds to the headers of .value) at a specific index.
    Another approach could be to read the data, process it separately and replace the existing data entirely:

    data = fda_attribute.value
    fda_attribute.clear()
    
    # Apply logic to modify `data`
    updated_data = apply_business_logic(data)
    
    for point in updated_data:
        fda_attribute.add_point(...) 
    

    The data can be loaded in pandas Dataframe if that helps with processing:

    import pandas as pd
    df = pd.Dataframe(data=fda_attribute.value[1:], columns=fda_attribute.value[0])
    

    I take your point about the lack of symmetry between reading and setting data and that's something we'll look into when trying to improve the interface.

    I hope this helps,
    Ludovic

Answers

  • Daniel Manocchio
    Daniel Manocchio Member Posts: 24
    5 Likes 10 Comments Photogenic
    **

    Hi Ludovic,
    thanks for your quick reply - although I somewhat feared an answer like that :D For performance reasons I tried to avoid processing that data Pandas, but I guess I'll give it a try now, haha.

    Thanks again & bests,
    Daniel