I'm trying to export a Julia dataframe into a CSV and it contains nothing values. To simiplify let's say I have the following dataframe:
using DataFrames, CSV
df = DataFrame(A = [nothing,2,3], B = [4,5,nothing])
When I try to export, I get the following error:
df |> CSV.write("df.csv")
ArgumentError: `nothing` should not be printed; use `show`, `repr`, or custom output instead.
Should I convert the nothing values to something else like missing? If so, how would I code this?
You can use something
function to convert nothing
to whatever you want (e.g. missing
) like this:
something.(df, missing) |> CSV.write("aaa.txt")
The current reasoning behind the design not to support nothing
when writing a CSV file is given here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With