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

标签 julia

我正在尝试将 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/

相关文章:

r - 从 R 问题中调用 Julia

julia - 内存高效中心稀疏 SVD/PCA(在 Julia 中)?

julia - 用户定义的中缀运算符

julia - 不精确错误 : Int64 even when checking divisibility

macros - 如何在 Julia 中给宏起别名

julia - 在 Julia 中通过 findfirst() 使用多个条件

julia - 如何迭代稀疏数组的非零值

memory-management - 使用 Julia 更新运算符进行不必要的分配

math - 为什么这个复数有理数会在 Julia 中出现溢出错误?

csv - 导入 csv 在 Jupyter 笔记本中的初始位置 Julia 中返回编码标识符