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