Skip to content

Commit d50c197

Browse files
proposed fix for mixed index dataframe bug
1 parent d1cd6ca commit d50c197

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

systems/portfolio.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -727,16 +727,20 @@ def _add_zero_weights_to_instrument_weights_df(
727727
instrument_list_to_add = (
728728
self.allocate_zero_instrument_weights_to_these_instruments()
729729
)
730-
weight_index = instrument_weights.index
731-
new_pd_as_dict = dict(
732-
[
733-
(instrument_code, pd.Series([0.0] * len(weight_index)))
734-
for instrument_code in instrument_list_to_add
735-
]
736-
)
737-
new_pd = pd.DataFrame(new_pd_as_dict)
738-
739-
padded_instrument_weights = pd.concat([instrument_weights, new_pd], axis=1)
730+
# weight_index = instrument_weights.index
731+
# new_pd_as_dict = dict(
732+
# [
733+
# (instrument_code, pd.Series([0.0] * len(weight_index)))
734+
# for instrument_code in instrument_list_to_add
735+
# ]
736+
# )
737+
# new_pd = pd.DataFrame(new_pd_as_dict)
738+
#
739+
# padded_instrument_weights = pd.concat([instrument_weights, new_pd], axis=1)
740+
741+
padded_instrument_weights = copy(instrument_weights)
742+
for zero_instr in instrument_list_to_add:
743+
padded_instrument_weights[zero_instr] = 0.0
740744

741745
return padded_instrument_weights
742746

0 commit comments

Comments
 (0)