静かに深化している julia の DataFames の describe()

R の summary() に比べると、いまひとつだった、julia の DataFrames の describe() という印象でした。しかし、静かに深化しています。

では、毎度、おなじみの iris を呼び出しましょう。

julia> using RDatasets

julia> iris = dataset("datasets", "iris");

では、describe() を使ってみましょう。

julia> @time describe(iris)
  0.000637 seconds (450 allocations: 24.531 KiB)
5×7 DataFrames.DataFrame
│ Row │ variable    │ mean    │ min     │ median  │ max     │ nmissing │ eltype                                     │
├─────┼─────────────┼─────────┼─────────┼─────────┼─────────┼──────────┼────────────────────────────────────────────┤
│ 1   │ SepalLength │ 5.84333 │ 4.3     │ 5.8     │ 7.9     │ nothing  │ Float64                                    │
│ 2   │ SepalWidth  │ 3.05733 │ 2.0     │ 3.0     │ 4.4     │ nothing  │ Float64                                    │
│ 3   │ PetalLength │ 3.758   │ 1.0     │ 4.35    │ 6.9     │ nothing  │ Float64                                    │
│ 4   │ PetalWidth  │ 1.19933 │ 0.1     │ 1.3     │ 2.5     │ nothing  │ Float64                                    │
│ 5   │ Species     │ nothing │ nothing │ nothing │ nothing │ nothing  │ CategoricalArrays.CategoricalString{UInt8} │

これはこれで、なかなか素敵です。

おまけで、RCall から、R の summary() を使ってみましょう。

julia> using RCall
INFO: Precompiling module RCall.

julia> R"summary($iris)"
RCall.RObject{RCall.StrSxp}
  SepalLength      SepalWidth     PetalLength      PetalWidth
 Min.   :4.300   Min.   :2.000   Min.   :1.000   Min.   :0.100
 1st Qu.:5.100   1st Qu.:2.800   1st Qu.:1.600   1st Qu.:0.300
 Median :5.800   Median :3.000   Median :4.350   Median :1.300
 Mean   :5.843   Mean   :3.057   Mean   :3.758   Mean   :1.199
 3rd Qu.:6.400   3rd Qu.:3.300   3rd Qu.:5.100   3rd Qu.:1.800
 Max.   :7.900   Max.   :4.400   Max.   :6.900   Max.   :2.500
       Species
 setosa    :50
 versicolor:50
 virginica :50

R の summary() の方が情報は多いです。

これを見ていると、boxplot() したくなりますね。おまけです。

julia> R"boxplot($iris)"
RCall.RObject{RCall.VecSxp}
$stats
     [,1] [,2] [,3] [,4] [,5]
[1,]  4.3  2.2 1.00  0.1    1
[2,]  5.1  2.8 1.60  0.3    1
[3,]  5.8  3.0 4.35  1.3    2
[4,]  6.4  3.3 5.10  1.8    3
[5,]  7.9  4.0 6.90  2.5    3

$n
[1] 150 150 150 150 150

$conf
         [,1]     [,2]     [,3]    [,4]     [,5]
[1,] 5.632292 2.935497 3.898477 1.10649 1.741987
[2,] 5.967708 3.064503 4.801523 1.49351 2.258013

$out
[1] 4.4 4.1 4.2 2.0

$group
[1] 2 2 2 2

$names
[1] "SepalLength" "SepalWidth"  "PetalLength" "PetalWidth"  "Species"

満足です。

B! LINE