我将一个表从SQL数据库导入到一个数据帧中,现在我正尝试通过describe()获取有关该数据帧的统计信息。我也尝试过head()。两者都会返回一个错误"ERROR: UndefVarError: describe not defined"。
我已经添加并导入了DataFrames包来解决这个问题,但它不起作用。
下面是我导入数据帧的方式:
using Pkg
Pkg.add("ODBC")
Pkg.add("DataFrames")
using ODBC, DataFrames
db = ODBC.DSN(connection_string)
query = ODBC.query(db, "SELECT * FROM table")
df = DataFrame(query)
describe(df)我期望得到一个类似于describe()或head() Python函数的结果。在运行head(df)之后,我预计会有列、标签和前几行。在运行describe(df)之后,我希望每个列标签都有min、max、avg、count等。
发布于 2019-04-26 05:55:35
有first而不是head。有关示例,请参阅以下代码:
julia> using DataFrames
julia> df = DataFrame(a=1:5,b=6:10)
5×2 DataFrame
│ Row │ a │ b │
│ │ Int64 │ Int64 │
├─────┼───────┼───────┤
│ 1 │ 1 │ 6 │
│ 2 │ 2 │ 7 │
│ 3 │ 3 │ 8 │
│ 4 │ 4 │ 9 │
│ 5 │ 5 │ 10 │
julia> first(df,3)
3×2 DataFrame
│ Row │ a │ b │
│ │ Int64 │ Int64 │
├─────┼───────┼───────┤
│ 1 │ 1 │ 6 │
│ 2 │ 2 │ 7 │
│ 3 │ 3 │ 8 │
julia> describe(df)
2×8 DataFrame
│ Row │ variable │ mean │ min │ median │ max │ nunique │ nmissing │ eltype │
│ │ Symbol │ Float64 │ Int64 │ Float64 │ Int64 │ Nothing │ Nothing │ DataType │
├─────┼──────────┼─────────┼───────┼─────────┼───────┼─────────┼──────────┼──────────┤
│ 1 │ a │ 3.0 │ 1 │ 3.0 │ 5 │ │ │ Int64 │
│ 2 │ b │ 8.0 │ 6 │ 8.0 │ 10 │ │ │ Int64 │https://stackoverflow.com/questions/55857808
复制相似问题