I have created a dataframe (df) which stores below information, HS1 is the index.
HS1 HS2 EffNotional_UnMG
EUR 3 -10082.91381
USD 2 -36253.84938
USD 3 78693.86806
Now I want to apply two ierations on this dataframe: outer by HS1 and the inner by HS2 so as to get two dictionaries (already declared with default values) as below: For EUR: {'2': 20000.00,'3':0} [Key 3 has 0 default value] For USD: {'2': -36253.84938, '3':78693.86806}
I used itertuple and get following output for the outer iteration:
for row in df.itertuples():
print (row)
Pandas(Index='EUR', HS2=3, EffNotional_UnMG=-10082.913813053281)
Pandas(Index='USD', HS2=2, EffNotional_UnMG=-36253.849384403635)
Pandas(Index='USD', HS2=3, EffNotional_UnMG=78693.868057473315)
Can one guide on proceed with the inner iteration using itertuples.