简体   繁体   中英

What is the Python (numpy or scipy or Pandas) equivalent for R's adjboxStats function?

I do use R to get the outliers for data set and I do use this snippet in R and it works like it's advertised to!

library("robustbase")
adjboxStats(c(11232.1, 234.2, 3445532344.3, 34302.3, 203.9, 232223.3, 3434.55), coef = 2.5, a = -4, b = 3, do.conf = TRUE, do.out = TRUE)

and I get this output:

$stats
[1]    203.900   1834.375  11232.100 133262.800 232223.300

$n
[1] 7

$conf
[1] -67254.84  89719.04

$fence
[1]   -6963.467 5097118.725

$out
[1] 3445532344

this is the versions of across language between R and python, the only issue with it it won't continue the execution and i have to kill the process every-time I run the script.

from rpy import *
r.library("robustbase")
import rpy2.robjects as robjects
r("adjboxStats")(r.c(11232.1, 234.2, 3445532344.3, 34302.3, 203.9, 232223.3, 3434.55), coef = 2.5, a = -4, b = 3, do_conf = True, do_out = True)

see my previous question was here for more info.

is there's away to get this working in pure python?

Thank you!

The hanging appears to happen when you import both rpy and rpy2 . If you just do:

from rpy import *
r.library("robustbase")
r("adjboxStats")(r.c(11232.1, 234.2, 3445532344.3, 34302.3, 203.9, 232223.3, 3434.55), coef = 2.5, a = -4, b = 3, do_conf = True, do_out = True)

This code should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM