gpt4 book ai didi

dataframe - 为什么 XLS​​X 创建的数据框的列类型总是输入 any

转载 作者:行者123 更新时间:2023-12-03 23:59:06 25 4
gpt4 key购买 nike

我在 excel 中有一些变量,我想将它们上传到 Julia 并估计一个线性模型。我的变量由实数组成,但是 XLSX 创建的 DataFrame 中的每一列都是 Any 类型。

我想知道 XLSX 是否有办法为每一列分配正确的类型。

谢谢

最佳答案

只需使用 infer_eltypes=true 这是一个示例:

julia> DataFrame(XLSX.readtable("file.xlsx",1;infer_eltypes=true)...)
3×3 DataFrame
│ Row │ col1 │ col2 │ col3 │
│ │ Int64 │ Float64 │ String │
├─────┼───────┼─────────┼────────┤
│ 1 │ 1 │ 4.5 │ txt1 │
│ 2 │ 2 │ 5.5 │ txt2 │
│ 3 │ 3 │ 6.7 │ txt3 │

关于dataframe - 为什么 XLS​​X 创建的数据框的列类型总是输入 any,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64896136/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com