Попытка найти выбросы листа Excel с помощью pandas в python. Я могу найти первый и третий квартили, но не могу вычесть одно из другого, не возвращая NaN
.
Вот необходимый код:
absent = pd.read_excel('Absenteeism_at_work.xls')
print("\nOUTLIERS:")
# q1 = (absent.loc[:741, ['Distance from Residence to Work']].quantile([0.25]))
# q3 = (absent.loc[:741, ['Distance from Residence to Work']].quantile([0.75]))
#print(absent.loc[:741, 'Distance from Residence to Work'].quantile([0.25])) #quartile
#print(q1)
# q1, q3 = absent.loc[:741, ['Distance from Residence to Work', 'Transportation expense', 'Month of absence',
# 'Social smoker', 'Social drinker', 'Education']].quantile([0.25 - 0.75])
print(absent.loc[:741, ['Distance from Residence to Work', 'Transportation expense', 'Month of absence',
'Social smoker', 'Social drinker', 'Education']].quantile([0.75])
- absent.loc[:741, ['Distance from Residence to Work', 'Transportation expense', 'Month of absence',
'Social smoker', 'Social drinker', 'Education']].quantile([0.25]))
ВЫХОД:
OUTLIERS:
Distance from Residence to Work Transportation expense \
0.25 NaN NaN
0.75 NaN NaN
Month of absence Social smoker Social drinker Education
0.25 NaN NaN NaN NaN
0.75 NaN NaN NaN NaN