I have two pandas arrays, A and B, that result from groupby operations. A has a 2-level multi-index consisting of both quantile and date. B just has an index for date.
Between the two of them, the date indices match up (within each quantile index for A).
Is there a standard Pandas function or idiom to "broadcast" B such that it will have an extra level to its multi-index that matches the first multi-index level of A?
If you just want to do simple arithmetic operations, I think something like A.div(B, level='date')
should work.
Alternatively, you can do something like B.reindex(A.index, level='date')
to manually match the indices.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With