nimble.ones¶
- nimble.ones(numPoints, numFeatures, pointNames='automatic', featureNames='automatic', returnType='Matrix', name=None)¶
Return a data object of the given shape containing all 1 values.
- Parameters:
numPoints (int) – The number of points in the returned object.
numFeatures (int) – The number of features in the returned object.
pointNames ('automatic', list, dict) – Names to be associated with the points in the returned object. If ‘automatic’, default names will be generated. Otherwise, may be specified explictly by some list-like or dict-like object, so long as all points in the data are assigned a name and the names for each point are unique.
featureNames ('automatic', list, dict) – Names to be associated with the features in the returned object. If ‘automatic’, default names will be generated. Otherwise, may be specified explictly by some list-like or dict-like object, so long as all features in the data are assigned a name and the names for each feature are unique.
returnType (str) – May be any of the allowed types specified in nimble.core.data.available. Default is “Matrix”.
name (str, None) – A string describing the data that will display when printing or logging the returned object. This value is also set as the name attribute of the returned object.
- Returns:
nimble.core.data.Base – Subclass of Base object corresponding with the
returnType
.
Examples
Ones with default names.
>>> ones = nimble.ones(5, 5, returnType='List') >>> ones <List 5pt x 5ft 0 1 2 3 4 ┌────────────── 0 │ 1 1 1 1 1 1 │ 1 1 1 1 1 2 │ 1 1 1 1 1 3 │ 1 1 1 1 1 4 │ 1 1 1 1 1 >
Named object of ones with pointNames and featureNames.
>>> onesDF = nimble.ones(4, 4, pointNames=['1', '2', '3', '4'], ... featureNames=['a', 'b', 'c', 'd'], ... returnType="DataFrame", ... name='ones DataFrame') >>> onesDF <DataFrame "ones DataFrame" 4pt x 4ft a b c d ┌─────────── 1 │ 1 1 1 1 2 │ 1 1 1 1 3 │ 1 1 1 1 4 │ 1 1 1 1 >
Keywords: matrix, 1, 1s