I have 2 dataframes, res_params
and res_tStats
. The columns and index is identical in both dataframes. It's only the values within each row and column (equivalent to "cells" in Excel if you will) that are different.
I need to get the index of the rows and columns from the res_tStats
dataframe where abs(res_tStats) > 1.96
and then apply formatting to the same index and rows in the res_params
data frame.
What I've done
# res_tStats is a NxM dataframe with shape (6, 4)
# res_params is a NXM dataframe with shape (6, 4)
idx_required = np.where(abs(res_tStats) > 1.96)
print(idx_required)
# output: array([0, 0, 0, 5, 5, 5, 5]), array([0, 2, 3, 0, 1, 2, 3]))
So far so good. It gave me the right index locations for where abs(res_tStats) > 1.96
.
The following values are in fact significant:
row 0, col 0
row 0, col 2
row 0, col 3
row 5, col 0
row 5, col 1
row 5, col 2
row 5, col 3
Now, when I apply these index locations to res_params
, I'm expecting to get the values at precisely the same index locations. However, I don't quite get that.
Running: res_params.iloc[idx_required]
returns a df of shape (7, 7).
I double checked by applying idx_required
to res_tStats
, expecting to get only the values > 1.96, however that didn't happen.
res_tStats.iloc[idx_required]
also returns a df of shape (7, 7) with some values within it being lower than 1.96