Vishvak Posted November 13 Posted November 13 Hi everyone, I am new to Seeq and need some guidance. I want to perform value searches in Data Lab and then push the results to Seeq Workbench. Here's why: I have a signal that identifies different vehicles, and I need to conduct value searches for each vehicle. My next task involves performing similar value searches but with different sets of vehicles. A pseudo code would be something like this: signal_data = spy.search(worksheet_url) items = spy.pull(worksheet_url) unique_vehicles = items["vehicles"].unique() ## Here I am looking for a code where I can make capsules for every value in unique_vehicles and push it to the workbench. Thanks in advance. Do let me know if I have missed to mention any more details.
Seeq Team Dan FR Posted November 18 Seeq Team Posted November 18 Hi Vishvak, Welcome to Seeq! Thank you for reaching out with your question. To assist you more effectively, could you please provide the following details: How many unique vehicles do you anticipate having? Can you elaborate on how your vehicle signal differentiates between the various vehicles? For instance, is this a string signal that changes string value each time a vehicle changes? Is there a specific reason you prefer to implement this within Data Lab instead of using Workbench tools? Thank you! Dan
Vishvak Posted November 18 Author Posted November 18 Hi Dan, Thanks for the reply... How many unique vehicles do you anticipate having? - Quote It is dynamic. I have no control over it. Can you elaborate on how your vehicle signal differentiates between the various vehicles? For instance, is this a string signal that changes string value each time a vehicle changes? Quote Yes, you are right. It is a string signal and changes from time to time. Is there a specific reason you prefer to implement this within Data Lab instead of using Workbench tools? Quote I am completely fine by using workbench tools. I just want to have an "wrapper" of sorts, which I can plug and play across other problems too... Like for instance, make a tool/asset, plug in the signal name, I would get all the distinct value searches and rinse and repeat for other cases. If I could make it a bit more clear, let me show you a code of what I am thinking (no, I am not looking for a python code, nor am I looking for just data lab solutions. Just making an effort to convey my thought) unique_vehicles = items["vehicles"].unique() for i in unique_vehicles: valueSearch(i) # The function which would make the value serach # Here, I can us this across projects to get my value searches. I would be completely relieved if I can achieve this in workbench too.
Seeq Team Solution Dan FR Posted November 18 Seeq Team Solution Posted November 18 (edited) Great! Thank you for the information. It makes perfect sense to want a reusable function. Let's proceed with implementing this in Python using Seeq Data Lab. Depending on your future use cases, you might consider utilizing Add-Ons or User Defined Functions for a more generic implementation. For the vehicles use case, the following code snippet will create a condition for each unique value in the Vehicle signal. These conditions will generate capsule whenever the corresponding value occurs. import pandas as pd # Get signal metadata signal_metadata = spy.search(workbook_url) # Retrieve actual signal data with signal name as the column header. Optionally specify your start/end date range. signal_data = spy.pull(signal_metadata, header='Name', start='YYYY-MM-DD MM:MM', end='YYYY-MM-DD MM:MM') # Loop through unique values of 'vehicles', create a new condition using formula and save these to a metadata dataframe. metadata_entries = [] for vehicle in signal_data['vehicles'].unique(): entry = { 'Name': f'{vehicle}', # Assign condition name based on the vehicle value. Change as required. 'Type': 'Condition', 'Formula': f'$v ~= "{vehicle}"', # This is the value search formula for matching a string signal. 'Formula Parameters': { '$v': signal_metadata[signal_metadata['Name'] == 'vehicles'] } } metadata_entries.append(entry) metadata=pd.DataFrame(metadata_entries) # Create metadata dataframe for new vehicle conditions. push_results = spy.push(metadata=metadata, workbook=workbook_id) # You can get the workbook_id from the workbook URL Please note that this will only evaluate unique values that fall within the date range specified in thespy.pull statement. If no date range is provided, the display range from the worksheet is used. Give this a try and let me know if it meets your requirements or if you have any further questions. Thank you, Dan Edited November 18 by Dan FR pandas import
Vishvak Posted November 19 Author Posted November 19 Thanks @Dan FR, Th(D)anks For Real, you are awesome!! It just works! 1
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