Home > Blockchain >  How to find where two columns have bigger difference/ are outliers python
How to find where two columns have bigger difference/ are outliers python

Time:10-02

I have these two arrays: (two random example arrays created)

x = [5,12,24,44,22,32,22]
y = [8,14,26,47,44,35,23]

These two columns are related and x[4] and y[4] are the outliers from this data

How would I go through a data frame and return the columns or column numbers which have the outliers in it?

Edit: Aplogoies. Here is the data frame:

df = pd.DataFrame({'x':x, 'y':y})

CodePudding user response:

Maybe this is too simplistic but seems to fulfil the brief:-

x = [5,12,24,44,22,32,22]
y = [8,14,26,47,44,35,23]
d = [abs(_x - _y) for _x, _y in zip(x, y)]
i = d.index(max(d))
print(x[i], y[i])
  • Related