guys I have tried official example. Found something on Internet, but still cannot get it right.
index | 2000 | 2001 |
---|---|---|
price | 1 | 2 |
price_real | 1.5 | 1.8 |
in above by table, I wanna run following test:
if df.loc['price_real'] > df.loc['price']:
if true, mark df.loc['price']
with 'background-color: green'
df.style.apply(lambda x: ['background-color: green']*len(df_s) if
(x.loc['stock_price_real'] > x.loc['stock_price']) else ['background-color: none']*len(df_s),
axis = 0)
above by code partially works, but I can’t force it to mark only df.loc['price']
row. I tried to add subset=pd.IndexSlice[['stock_price'], :]
, but it ends up by error.
There is example of my program, but it marks also all rows below or above.
Any suggestion, please?
only df.loc['price']
row marked if true