Mohammad Reza Babaei Posted November 26, 2022 Posted November 26, 2022 Hi, Can users access the signal's variable name in the data lab? It would be great to have it as a column when calling spy.search(worksheet_url ...). For example:
Seeq Team Mark Derbecker Posted November 26, 2022 Seeq Team Posted November 26, 2022 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') merged_df It'll look like this:
Mohammad Reza Babaei Posted November 27, 2022 Author Posted November 27, 2022 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] else: if len(name_i_list[0]) > 4: f_name += name_i_list[0][0] else: f_name += name_i_list[0] formula_name.append(f_name) return formula_name However, this is not a perfect solution.
Seeq Team Mark Derbecker Posted November 27, 2022 Seeq Team Posted November 27, 2022 It is better to correlate the calculation variables with the stored signals by using the ID -- the name of the variable can be anything, so it is not a reliable link between the two.
Mohammad Reza Babaei Posted November 27, 2022 Author Posted November 27, 2022 Thank you very much Mark! I will do that.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now