This workflow is an example of the use of mesh scoping for the input of a result reader. Here, you can extract a mesh scoping (a set of spatial entities: node or elements for example) from a named selection created in Mechanical or Mechanical APDL. This mesh scoping is then used as an input for a strain tensors reader. The output of this workflow is the elemental mean of normal elastic strain on X axis scoped only on the named selection.
import mech_dpf
import Ans.DataProcessing as dpf
my_data_sources = dpf.DataSources(analysis.ResultFileName)
ns_op = dpf.operators.scoping.on_named_selection()
ns_op.inputs.data_sources.Connect(my_data_sources)
# first version with elemental scoping
ns_op.inputs.requested_location.Connect('Elemental')
ns_op.inputs.int_inclusive.Connect(1)
ns_op.inputs.named_selection_name.Connect('SELECTION')
strain_op = dpf.operators.result.elastic_strain_X()
strain_op.inputs.data_sources.Connect(my_data_sources)
strain_op.inputs.mesh_scoping.Connect(ns_op.outputs.mesh_scoping)
# make an elemental average on the elemental nodal field
to_elemental_op = dpf.operators.averaging.to_elemental_fc()
to_elemental_op.Connect(strain_op)
dpf_workflow = dpf.Workflow()
dpf_workflow.Add(ns_op)
dpf_workflow.Add(strain_op)
dpf_workflow.Add(to_elemental_op)
dpf_workflow.SetOutputContour(to_elemental_op, dpf.enums.GFXContourType.FEElementalScoping)
dpf_workflow.Record('wf_id', True)
this.WorkflowId = dpf_workflow.GetRecordedId()

Note:
The Name Selection name must match what was used in the input file. For example, if you are using the MAPDL solver, irrespective of the name used in Mechanical, the name of the selection is written as an upper-case string in the input file.
Regarding the location of the strain operator (ElementalNodal location), and using the elemental averaging operator, it shows how to chain several operators.
A better scoping representation can be utilized by setting a proper enum for different contour scoping types:
dpf_workflow.SetOutputContour(to_elemental_op, dpf.enums.GFXContourType.FEElementalScoping)