Description

Check the size of a vector. if size is not match, then do as handleInvalid.

Parameters

Name Description Type Required? Default Value
size size of some thing. Integer
handleInvalidMethod the handle method of invalid value. include: error, optimistic String “error”
selectedCol Name of the selected column used for processing String
outputCol Name of the output column String null
reservedCols Names of the columns to be retained in the output table String[] null

Script Example

Script

  1. data = np.array([["$8$1:3,2:4,4:7"],["$8$2:4,4:5"]])
  2. df = pd.DataFrame({"vec" : data[:,0]})
  3. data = dataframeToOperator(df, schemaStr="vec string",op_type="batch")
  4. model = VectorSizeHint().setSelectedCol("vec").setOutputCol("vec_hint").setHandleInvalidMethod("optimistic").setSize(8)
  5. model.transform(data).collectToDataframe()

Result

vec vec_hint
$8$1:3,2:4,4:7 $8$1:3.0 2:4.0 4:7.0
$8$2:4,4:5 $8$2:4.0 4:5.0