Nan Error in CSV

I have a CSV file which contains about 1500 values some of which are “nan”, I am trying to write a function that would replace the “nan” values with zero.

I tried using the replace_nan(v) and CSV write function, however have been unsuccesful.

P.S. I am julia beginer, so any help will be appreicated.

One thing you could do is use missingstring = "nan" to read in the NaN values as missing, then perform replace(col, missing => NaN) on all the columns that should have NaN values.

1 Like

replace(x, NaN => 0), (or replace!(x, NaN => 0) if you want to do in-place replacement) should work in many circumstances. Can you post a minimum reproducible example where that does not work?

Please consider the following recommendations to post your example: