Jump to content

Pulling signal's variable name

Mohammad Reza Babaei

Recommended Posts

  • Seeq Team

Hi Mohammad,

When you include the "all_properties=True" argument in spy.search(), you will receive a "Formula Parameters" column that has the variables as a list of strings in the form "variable_name=item_id" like so:


To get exactly the DataFrame you're asking for in your original post, you can then use the following DataFrame manipulation code and another call to spy.search():

variables_df = pd.DataFrame([{'Variable Name': f"${fp.split('=')[0]}", 'ID': fp.split('=')[1]}
                             for fp in search_df.iloc[0]['Formula Parameters']])
merged_df = spy.search(variables_df)
merged_df = merged_df[['ID', 'Name', 'Type']]
merged_df = merged_df.merge(variables_df, on='ID')

It'll look like this:


Link to comment
Share on other sites

That's great! Thanks, Mark.

I wanted to start writing a formula using Stored Signals in Data Lab. In this case, I will get the following:


I tried to write a function for converting "Name" to "Variable Name":

from re import split

def create_formula_variable_name(names):
    formula_name = []
    for name_i in names:
        name_i_lower = name_i.lower()
        name_i_list = split("_| | ", name_i_lower)
        f_name = '$'
        cnt = 0
        if len(name_i_list) > 1:
            for i in name_i_list:
                f_name += i[0]
            if len(name_i_list[0]) > 4:
                f_name += name_i_list[0][0]
                f_name += name_i_list[0]


    return formula_name

However, this is not a perfect solution.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...