Base.flatten¶
- Base.flatten(order='point', *, useLog=None)¶
Modify this object so that its values are in a single point.
Each value in the result maps to exactly one value from the original object. For data in two-dimensions,
order
may be ‘point’ or ‘feature’. If order=’point’, the first n values in the result will match the original first point, the nth to (2n-1)th values will match the original second point and so on. If order=’feature’, the first n values in the result will match the original first feature, the nth to (2n-1)th values will match the original second feature and so on. For higher dimension data, ‘point’ is the only acceptedorder
. If pointNames and/or featureNames are present. The feature names of the flattened result will be formatted as “ptName | ftName”. This is an inplace operation.- Parameters:
order (str) – Either ‘point’ or ‘feature’.
useLog (bool, None) – Local control for whether to send object creation to the logger. If None (default), use the value as specified in the “logger” “enabledByDefault” configuration option. If True, send to the logger regardless of the global option. If False, do NOT send to the logger, regardless of the global option.
See also
Examples
>>> lst = [[1, 2], ... [3, 4]] >>> ptNames = ['1', '3'] >>> ftNames = ['a', 'b'] >>> X = nimble.data(lst, pointNames=ptNames, ... featureNames=ftNames) >>> X.flatten() >>> X <Matrix 1pt x 4ft 1 | a 1 | b 3 | a 3 | b ┌─────────────────────────── Flattened │ 1 2 3 4 >
>>> lst = [[1, 2], ... [3, 4]] >>> ptNames = ['1', '3'] >>> ftNames = ['a', 'b'] >>> X = nimble.data(lst, pointNames=ptNames, ... featureNames=ftNames) >>> X.flatten(order='feature') >>> X <Matrix 1pt x 4ft 1 | a 3 | a 1 | b 3 | b ┌─────────────────────────── Flattened │ 1 3 2 4 >
Keywords: reshape, restructure, ravel, one dimensional, 1 dimensional