CSV.write()回報:ERROR: LoadError: StackOverflowError:進一步向下索賠--- the last 2 lines are repeated 39990 more times ---。這是無稽之談,因為要寫入的資料幀被確認為 129x6 維度,沒有空欄位。我擔心該函式正在計算超出資料框維度的行數,不應該這樣做。如何使此功能起作用?
using CSV,DataFrames
file=DataFrame(
a=1:50,
b=1:50,
c=Vector{Any}(missing,50),
d=Vector{Any}(missing,50))
CSV.write("a.csv",file)
file=CSV.read("a.csv",DataFrame)
c,d=[],[]
for i in 1:nrow(file)
push!(c,file.a[i]*file.b[i])
push!(d,file.a[i]*file.b[i]/file.a[i])
end
file[!,:c]=c
file[!,:d]=d
# I found no straight forward way to fill empty columns based on the values of filled columns in a for loop that wouldn't generate error messages
CSV.write("a.csv",DataFrame) # Error in question here
uj5u.com熱心網友回復:
StackOverflowError 確實是由于該行
CSV.write("a.csv",DataFrame)
它試圖將資料型別本身寫入檔案而不是實際的資料幀變數。(導致此特定錯誤的原因是此處描述的實作細節。)
# I found no straight forward way to fill empty columns based on the values of filled columns in a for loop that wouldn't generate error messages
你不需要一個for回圈,只是
file.c = file.a .* file.b
file.d = file.a .* file.b ./ file.a
將完成這項作業。(雖然我不明白file.d計算的重點——也許這只是你為了說明而選擇的一個示例虛擬計算。)
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/515539.html
標籤:数据框CSV朱莉娅
上一篇:檢查用戶的回答是狀態之一
