I am trying to compare two timeseries dataframes with different dimensions.
Market_Cap
Date Stock_A Stock_B Stock_C
01.01.1990 1 3 7
01.02.1990 2 4 8
01.03.1990 3 5 1
01.04.1990 4 6 2
Market_Cap_quantiles
Date Bottom_quantile
01.01.1990 1.4
01.02.1990 2.4
01.03.1990 1.4
01.04.1990 2.4
Is there an elegant solution that checks each row of Market_Cap if the stocks belonges in the Market_Cap_quantile, and if not replace the value by NA. So that I end up with something like this:
Bottom_Stocks
Date Stock_A Stock_B Stock_C
01.01.1990 1 NA NA
01.02.1990 2 NA NA
01.03.1990 NA NA 1
01.04.1990 NA NA 2
I would greatly appreciate your help!