qis.df_to_weight_allocation_sum1¶
- qis.df_to_weight_allocation_sum1(df)[source]¶
normalise each row to sum to one.
Signed values are kept, so a row with short positions produces weights summing to one that include negatives - this is the general normaliser. Use
df_to_long_only_allocation_sum1()when negatives should be dropped instead.- Parameters:
df (Series | DataFrame) – scores or notionals, one column per asset. NaN is treated as zero in the row sum and the resulting weight is zero
- Returns:
- weights in the same shape, each row summing to one, or to zero when the input row has no
gross exposure
- Raises:
ValueError – if signed values have positive gross exposure but a net sum numerically equal to zero, because no finite proportional sum-to-one normalization exists
- Return type: