Julia - describe() 函数显示不完整的汇总统计信息
Julia - describe() function display incomplete summary statistics
我正在尝试使用 Julia 进行基本数据分析
我正在使用以下代码关注 this tutorial with the train datasets that can be found here(名为 train_u6lujuX_CVtuZ9i.csv
的那个):
using DataFrames, RDatasets, CSV, StatsBase
train = CSV.read("/Path/to/train_u6lujuX_CVtuZ9i.csv");
describe(train[:LoanAmount])
并得到这个输出:
Summary Stats:
Length: 614
Type: Union{Missing, Int64}
Number Unique: 204
而不是教程的输出:
Summary Stats:
Mean: 146.412162
Minimum: 9.000000
1st Quartile: 100.000000
Median: 128.000000
3rd Quartile: 168.000000
Maximum: 700.000000
Length: 592
Type: Int64
% Missing: 3.583062
这也对应于 describe()
函数应该给出的 StatsBase.jl 的输出
这是目前(在当前版本中)在 StatsBase.jl 中的实现方式。简而言之,train.LoanAmount
没有 eltype
是 Real
的子类型,然后 StatsBase.jl 使用仅打印长度、eltype 和唯一值数量的后备方法。您可以写 describe(collect(skipmissing(train.LoanAmount)))
来获取汇总统计信息(当然,缺失的数量除外)。
不过,实际上,我建议您使用另一种方法。如果您想在单列上获得更详细的输出,请使用:
describe(train, :all, cols=:LoanAmount)
您将获得一个额外作为 DataFrame
返回的输出,这样您不仅可以看到统计数据,还可以访问它们。
选项 :all
将打印所有统计信息,请参阅 DataFrames.jl 中的 describe
文档字符串以查看可用选项。
您可以在 DataFrames.jl here.
的当前版本中找到一些使用此函数的示例
我正在尝试使用 Julia 进行基本数据分析
我正在使用以下代码关注 this tutorial with the train datasets that can be found here(名为 train_u6lujuX_CVtuZ9i.csv
的那个):
using DataFrames, RDatasets, CSV, StatsBase
train = CSV.read("/Path/to/train_u6lujuX_CVtuZ9i.csv");
describe(train[:LoanAmount])
并得到这个输出:
Summary Stats:
Length: 614
Type: Union{Missing, Int64}
Number Unique: 204
而不是教程的输出:
Summary Stats:
Mean: 146.412162
Minimum: 9.000000
1st Quartile: 100.000000
Median: 128.000000
3rd Quartile: 168.000000
Maximum: 700.000000
Length: 592
Type: Int64
% Missing: 3.583062
这也对应于 describe()
函数应该给出的 StatsBase.jl 的输出
这是目前(在当前版本中)在 StatsBase.jl 中的实现方式。简而言之,train.LoanAmount
没有 eltype
是 Real
的子类型,然后 StatsBase.jl 使用仅打印长度、eltype 和唯一值数量的后备方法。您可以写 describe(collect(skipmissing(train.LoanAmount)))
来获取汇总统计信息(当然,缺失的数量除外)。
不过,实际上,我建议您使用另一种方法。如果您想在单列上获得更详细的输出,请使用:
describe(train, :all, cols=:LoanAmount)
您将获得一个额外作为 DataFrame
返回的输出,这样您不仅可以看到统计数据,还可以访问它们。
选项 :all
将打印所有统计信息,请参阅 DataFrames.jl 中的 describe
文档字符串以查看可用选项。
您可以在 DataFrames.jl here.
的当前版本中找到一些使用此函数的示例