Scale Values
[1]:
%config Completer.use_jedi = False
Values can be associated to scales in one object instance. They are internally represented as pandas.Series
.
[2]:
from mcda.values import Values
[3]:
values = Values([0, -2, 5, 10, 3])
Any type compatible with the pandas.Series
constructor can be used to supply values.
[4]:
from mcda import normalize
normalize(values).data
[4]:
0 0.166667
1 0.000000
2 0.583333
3 1.000000
4 0.416667
dtype: float64
[5]:
values.sort().data
[5]:
3 10
2 5
4 3
0 0
1 -2
dtype: int64
[6]:
values.is_within_scales
[6]:
True
You can acess individual values and iterate over them as you would with an immutable mapping:
[7]:
values[0]
[7]:
<Value value=0 scale=QuantitativeScale(interval=[-2, 10])>
[8]:
values[0].value
[8]:
0
[9]:
for k, v in values.items():
print(f"{k} -> {v}")
0 -> Value(value=0, scale=QuantitativeScale(interval=[-2, 10]))
1 -> Value(value=-2, scale=QuantitativeScale(interval=[-2, 10]))
2 -> Value(value=5, scale=QuantitativeScale(interval=[-2, 10]))
3 -> Value(value=10, scale=QuantitativeScale(interval=[-2, 10]))
4 -> Value(value=3, scale=QuantitativeScale(interval=[-2, 10]))