build_allocations(df, agg_lvl, start_date='2023-01-01', end_date='2023-12-31', drop_zero=False)
Build a series where groupby(agg_lvl).sum() = 1.0 or 0.0 because it represent a percentage allocation
Source code in wt_ml/dataset/dma_utils.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
|
map_midx(df, lvl_name, lvl_map, axis=1, name=None)
Modify a multiindex of a pandas object to have new values via mapping different names on a level
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df |
PandasObject
|
object in which to modify the multi index |
required |
lvl_name |
str
|
level name of the multi index to modify |
required |
lvl_map |
dict[str, str]
|
specification of how to change the names of values in the level of the mult index |
required |
axis |
int
|
If 1, modify columns, if 0 modify index. Defaults to 1. |
1
|
name |
str
|
if not None, this will insert a new level of this name above the level with level_name. used for things like parent_signal and converting state to region. |
None
|
Returns:
Name | Type | Description |
---|---|---|
PandasObject |
PandasObject
|
Copy of original |
Source code in wt_ml/dataset/dma_utils.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
|