Tayyab Posted August 14, 2024 Posted August 14, 2024 (edited) I'm looking to pull current values for a large number of signals. What's the most efficient way to use spy.pull to do this? For example, I'm trying to recreate this table that I can produce in table view by bringing in the "Last Value" column. In my use case I am bringing in data from PI and just need the latest value - regardless of timestamp. Would going with endtime = now() be the best option with aggregation using endkey? Edited August 14, 2024 by Tayyab
Seeq Team John Cox Posted December 9, 2024 Seeq Team Posted December 9, 2024 Hello, very sorry for the long delay time on this response. We overlooked your post. There are many ways to do this, here is one potential approach in Data Lab: from seeq import spy import pandas as pd from datetime import datetime, timedelta # Define current time in your time zone current_time = pd.Timestamp.now(tz='US/Eastern') # Define a start time slightly before the current time start_time = current_time - timedelta(minutes=1) # Pull data for all signals in the worksheet URL specified, set grid time to only get back one value data=spy.pull('Seeq worksheet_url',start=start_time.isoformat(),end=current_time.isoformat(),grid='1min')
Seeq Team Solution John Cox Posted December 9, 2024 Seeq Team Solution Posted December 9, 2024 Also, if you have one or more signals you are pulling which do not have a value near current time and return NaN instead of the desired numeric or string value, you can add a "calculation" parameter in the spy.pull to "hold" the last value forward up to the amount of time you specify. In the example below I used 30 minutes, but for lab data or other types of infrequently updating signals, you may need to make the time parameter significantly longer: # Pull data for all signals in the worksheet URL specified, set grid time to only get back one value, use resampleHold to help with infrequently updating values data=spy.pull('Seeq worksheet_url',start=start_time.isoformat(),end=current_time.isoformat(),calculation='$signal.resampleHold(30min)',grid='1min')
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