gpt4 book ai didi

julia - CSV.write() 不会取任何值

转载 作者:行者123 更新时间:2023-12-04 19:25:36 25 4
gpt4 key购买 nike

我正在尝试将 Julia 数据框导出到 CSV 中,但它不包含任何值。为了简化,假设我有以下数据框:

using DataFrames, CSV

df = DataFrame(A = [nothing,2,3], B = [4,5,nothing])

当我尝试导出时,出现以下错误:
df |> CSV.write("df.csv")

ArgumentError: `nothing` should not be printed; use `show`, `repr`, or custom output instead.

我应该将无值转换为其他值吗?如果是这样,我将如何编码?

最佳答案

您可以使用 something转换函数 nothing任何你想要的(例如 missing )像这样:

something.(df, missing) |> CSV.write("aaa.txt")

不支持设计背后的当前推理 nothing写入 CSV 文件时给出 here .

关于julia - CSV.write() 不会取任何值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58277727/

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