Python command: Statistics

Use the Statistics commands in Python to view calculated statistics for a specific SPC or DMS retrieval. This allows you to view any statistic GainSeeker calculates and any custom statistics you have previously created. Access values in Pareto, OEE, or DPU Detail tables and view the raw data associated with a retrieval.

Also see Python command: Retrieval

See Python commands for other commands you can use with GainSeeker.

 

Contents  [Hide]

 

Shared DMS and SPC commands

Syntax

Example

Description/Remarks

New or changed in GainSeeker version

[statspc/statdms].getstat(index)  

statspc.getstat(100)

statdms.getstat(45)

Returns an SPC or DMS statistic based on its index.

For SPC: SPC statistics available

For DMS: DMS statistics available

 

[statspc/statdms].getstatstr(index) 

statspc.getstatstr(100)

statdms.getstatstr(45)

Returns the display string of an SPC or DMS statistic based on its index.

For SPC: SPC statistics available

For DMS: DMS statistics available

 

[statspc/statdms].helpers.average(list)

x = [4, 10, 8]

statdms.helpers.average(x)

Returns an average of the values. Returns None if a non-numeric, non-empty value is found.

 

[statspc/statdms].helpers.count(list, value)

x = [4, 10, 8, 4]

statdms.helpers.count(x, 4)

Returns the number of times a value appears in a list. Can be used with a mixture of text and numbers.

 

[statspc/statdms].helpers.countregex(list, regex)

x = ["goodbye", "8000", "good", "hello"]

statdms.helpers.countregex(x, "\d+")

Returns the number of elements in a list that match a regular expression. Can be used with a mixture of text and numbers.

Quick reference for regular expressions (regex)

 

[statspc/statdms].helpers.sum(list)

x = [4, 10, 8]

statdms.helpers.sum(x)

Returns the sum of a list of numbers. Returns None if a non-numeric, non-empty value is found.

 

[statspc/statdms].helpers.unique(list)

x = [4, 10, 8, 4]

statdms.helpers.unique(x)

Returns the number of unique values are in a list.

None is considered a unique value.

 

SPC data commands

The statspc.data.method commands return the underlying data for a retrieval.

There is a separate command for each column in an SPC data table, and each of these commands returns a list of values for its data table column.

Syntax

Example

Description/Remarks

New or changed in GainSeeker version

statspc.data.actiontaken()

listAction = statspc.data.actiontaken()

Returns a list containing one item for each row of data in the retrieval.

Each item in the list is the Action Taken (long description) for that row of data, or None if no Action Taken is set for that row.

 

statspc.data.anchorpoint()

listAnchorpoint = statspc.data.anchorpoint()

Returns a list containing one item for each row of data in the retrieval.

Each item in the list is the Anchor Point setting for that row of data - True if that row is set as an Anchor Point and False if that row is not set as an Anchor Point.

 

statspc.data.cause()

listCause = statspc.data.cause()

Returns a list containing one item for each row of data in the retrieval.

Each item in the list is the Cause (long description) for that row of data, or None if no Cause is set for that row.

 

statspc.data.datapts()

listData = statspc.data.datapts()

Returns a list containing one item for each row of data in the retrieval.

Each item in the list is a list of all of the numeric measurements (or None if the inspector entered * for a missing measurement) for that row of data. (So this command actually returns a list of lists.)

 

statspc.data.datetime()

listDatetimeInt = statspc.data.datetime()

Returns a list containing one item for each row of data in the retrieval.

Each item in the list is a 17-digit integer representation of the Date/Time (yyyyMMddHHmmssfff) for that row of data.

See also: Python command: HSI Date, Microsoft .Net date and time format strings

 

statspc.data.datetimedisp(includedate=True, includetime=True)

listDatetime = statspc.data.datetimedisp()

Sets the variable to a list of Date/Time stamps for the retrieved data.

listDate = statspc.data.datetimedisp(includetime=False)

listDate = statspc.data.datetimedisp(True, False)

Both examples set the variable to a list of Date stamps for the retrieved data.

listTime = statspc.data.datetimedisp(False)

listTime = statspc.data.datetimedisp(False, True)

Both examples set the variable to a list of Time stamps for the retrieved data

Returns a list containing one item for each row of data in the retrieval.

Each item in the list is a display string of the Date, Time, or Date/Time for that row of data.

The display string is affected by the Show time to configuration setting and the Language - Spanish, French, or English - for the module that is running the script (PC Collect or GainSeeker Charts).

To suppress the Date portion of the date/time, set the includedate argument to False.

To suppress the Time portion of the date/time, set the includetime argument to False.

8.8

statspc.data.eventspc()

listEvent = statspc.data.eventspc()

Returns a list containing one item for each row of data in the retrieval.

Each item in the list is the Event (long description) for that row of data, or None if no Event is set for that row.

 

statspc.data.note()

listNote = statspc.data.note()

Returns a list containing one item for each row of data in the retrieval.

Each item in the list is the Note for that row of data, or None if no Note exists for that row.

Each note may contain a real-time failure note, a user-entered note, or both.

8.9

statspc.data.outlier()

listBypass = statspc.data.outlier()

Returns a list containing one item for each row of data in the retrieval.

Each item in the list is a number that represents the Bypass setting for that row of data:

0 : Not bypassed ("Include in statistics and show on charts")

-1 : Bypassed from statistics ("Remove from statistics but show on charts")

-2 : Bypassed from ordinary retrievals and statistics ("Remove from statistics and hide from charts"). The only way to retrieve this data is to use a

 

statspc.data.partno()

list = statspc.data.partno()

Returns a list containing one item for each row of data in the retrieval.

Each item in the list is the SPC standard for that row of data.

 

statspc.data.rowcnt

myrowcount = statspc.data.rowcnt

Returns the number of data rows in the retrieval.

 

statspc.data.rtf()

listRTFcodes = statspc.data.rtf()

Returns a list containing one item for each row of data in the retrieval.

Each item in the list is a number that represents all of the real-time failures (if any) that occurred in that row of data.

For a reference of the failures represented by the returned number, see Real-time Failure codes.

 

statspc.data.rtfstr()

listRTFdescript = statspc.data.rtfstr()

Returns a list containing one item for each row of data in the retrieval.

Each item in the list is a list of all of the real-time failure descriptions (if any) that occurred in that row of data. (So this command actually returns a list of lists.)

 

statspc.data.trace(index)

list = statspc.data.trace(4)

Returns a list containing one item for each row of data in the retrieval.

index indicates which traceability field you want to return.

Each item in the list is a traceability value for that row of data.

 

DMS commands

Syntax

Example

Description/Remarks

New or changed in GainSeeker version

statdms.data.method

(use code completion to choose a method)

statdms.data.note()

Gives access to the underlying data for a retrieval.

All columns in a DMS data table are available. Calling a method under data returns the values for the associated data table column.

Returns a list.

8.9

statdms.dpu.method

(use code completion to choose a method)

statdms.dpu.dpm()

statdms.dpu.sigma()

Gives access to the DPU Detail table columns for a retrieval. Calling a method under dpu returns the values for the column that shares its name with the method.

Returns a list.

 

statdms.oee.method

(use code completion to choose a method)

statdms.oee.oeeavailability()

statdms.oee.sumdowntime()

Gives access to the OEE Detail table columns for a retrieval. Calling a method under oee returns the values for the column that shares its name with the method.

Returns a list.

 

statdms.pareto.method

(use code completion to choose a method)

statdms.pareto.ncucost()

statdms.pareto.percenttotalcost()

statdms.pareto.defectcost()

Gives access to the Pareto Detail table columns for a retrieval. Calling a method under pareto returns the values for the column that shares its name with the method.

Returns a list.

 

Example script

This script retrieves and displays the Note values for one SPC standard and one DMS standard:

 

retrspc.partno = "RH HEADLIGHT 01142 - 06B FLUSH"
list_notes = statspc.data.note()

for x in list_notes:
    
if x != None:
        
print x
        

retrdms.partno =
"A-50 INSERT"
retrdms.process =
"M-CUT OFF"
list_dms_notes = statdms.data.note()

for x in list_dms_notes:
    
if x != None:
        
print x