Jump to content

Pushing existing tags from a spy.search into a Workbench Analysis.


Robert Rhodes

Recommended Posts

I am trying to push a curated dataframe of existing tags that was queried with a spy.search then dropna was done on "Estimated Sample Period" to remove stale tags.  Any ideas on how to do this? I would also like to perform the formula function .convertUnits('eu') in the process. 
 Any tips, trick, ideas would be appreciated.

Link to comment
Share on other sites

@Ken How,
When I do spy.search and specify the estimate_sample_period for a day and if there is data on a signal it will come back with a timestamp, if it does not have data, it will return a NAT for that signal.  After that step the dataframe.dropna(subset=['Estimated Sample Period']) can be used to remove NAT rows as well.  Then I am left with a dataset of good tags that I want to insert into a Workbench after doing the convert. 

spy.search({
    'Name': 'Area ?_Compressor Stage',
    'Datasource Name': 'Example Data'
}, estimate_sample_period=dict(Start='2019-01-01', End='2019-01-30'))


image.png

Edited by Robert Rhodes
Link to comment
Share on other sites

  • Seeq Team

Hi Robert, 

After the spy.search and dropNA step, you can create a metadata to convert the unit of the selected signals and push it to Seeq workbench. 

#Search for tags and dropNA
search_df = spy.search({
    'Name': 'Area ?_Compressor Stage',
    'Datasource Name': 'Example Data'
}, estimate_sample_period=dict(Start='2019-01-01', End='2019-01-30'))

search_df = search_df.dropna(subset=['Estimated Sample Period'])

# Create a copy of the search table so we can manipulate it
formulas = search_df.copy()

formulas

#Create the metadata
formulas['Name'] = formulas['Name'] + '_convertunit'
formulas['Formula'] = '$signal.convertUnits(\'C\')' #For this example, I am converting the unit to DegC. 
formulas['Formula Parameters'] = '$signal=' + formulas['ID']
formulas.head()

#Push the metadata to Seeq workbench
spy.push(metadata = formulas[['Name', 'Formula', 'Formula Parameters']],
         worksheet='Unit Conversion')

 

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...