BracketEnd
Source¶
Bases: Enum
Whether the first or the last bracket of Brackets stops at a limit or holds every value beyond it.
Added in version 0.1.0
Examples:
import numdaplot as ndp
ages = ndp.Table.from_arrays({"age": ndp.Array.from_list([4, 30, 92])})
brackets = ndp.Brackets(limits=[0, 18, 65], last=ndp.BracketEnd.OPEN)
age_groups = ages.convert(ndp.TableConversion(columns=["age"], dtype=ndp.Type.CATEGORY, format=brackets))
age_groups.column("age").to_list()
# ['0 to 17', '18 to 64', '65 or more']
Attributes¶
CLOSED = auto()
Source¶
The bracket stops at its limit. Default value.
Added in version 0.1.0
Examples:
import numdaplot as ndp
ages = ndp.Table.from_arrays({"age": ndp.Array.from_list([4, 30])})
brackets = ndp.Brackets(limits=[0, 18, 65], last=ndp.BracketEnd.CLOSED)
age_groups = ages.convert(ndp.TableConversion(columns=["age"], dtype=ndp.Type.CATEGORY, format=brackets))
age_groups.column("age").to_list()
# ['0 to 17', '18 to 64']
OPEN = auto()
Source¶
The bracket holds every value beyond the limit: below the first one, or above the last one.
Added in version 0.1.0
Examples:
import numdaplot as ndp
temperatures = ndp.Table.from_arrays({"celsius": ndp.Array.from_list([-3.5, 12.0])})
brackets = ndp.Brackets(limits=[0, 15], first=ndp.BracketEnd.OPEN)
conversion = ndp.TableConversion(columns=["celsius"], dtype=ndp.Type.CATEGORY, format=brackets)
temperatures.convert(conversion).column("celsius").to_list()
# ['under 0', '0 to under 15']