Let df1
, df2
, and df3
are pandas.DataFrame
's having the same structure but different numerical values. I want to perform:
res=if df1>1.0: (df2-df3)/(df1-1) else df3
res
should have the same structure as df1
, df2
, and df3
have.
numpy.where()
generates result as a flat array.
Edit 1:
res
should have the same indices as df1
, df2
, and df3
have.
For example, I can access df2
as df2["instanceA"]["parameter1"]["paramter2"]
. I want to access the new calculated DataFrame/Series res
as res["instanceA"]["parameter1"]["paramter2"]
.