Skip to content

Latest commit

 

History

History
46 lines (31 loc) · 854 Bytes

File metadata and controls

46 lines (31 loc) · 854 Bytes

Description

Sample with given size with or without replacement.

Parameters

Name Description Type Required? Default Value
size sampling size Integer
withReplacement Indicates whether to enable sampling with replacement, default is without replcement Boolean false

Script Example

Script

data = data = np.array([
       ["0,0,0"],
       ["0.1,0.1,0.1"],
       ["0.2,0.2,0.2"],
       ["9,9,9"],
       ["9.1,9.1,9.1"],
       ["9.2,9.2,9.2"]
])
    
df = pd.DataFrame({"Y": data[:, 0]})

# batch source 
inOp = dataframeToOperator(df, schemaStr='Y string', op_type='batch')

sampleOp = SampleWithSizeBatchOp()\
        .setSize(2)\
        .setWithReplacement(False)

inOp.link(sampleOp).print()

Result

Y
0,0,0
0.2,0.2,0.2