0

Lets assume i have two dataframes (they are a result of tukeys outlier filter method fyi). The data is such, that df1 is either enclosed by df2, df2 >df1 or df2>df1. But df2 and df1 have no common values in any case.

How do i check which case is present, and how do i detect the edges of the enclosing interval quickly. I currently do it like this but his seems rather blunt:

def get_enclosing_edges(df1,df2):
    e=[None]
    if df1.max() < df2.min():
        e = [df1.max()]
    if df1.max() > df2.min():
        e [df1.min()]
    if (df2 > df1.max()).any() and (df2 < df1.min()).any():
        e = [df1.min(),df1.max()]
    return e
NorrinRadd
  • 545
  • 6
  • 21

0 Answers0