Thanks, Here's my first try restricted to Float64:
function replaceNaN(df) nrows, ncols = size(df) for row in 1:nrows for col in 1:ncols v = df[row,col] if typeof(v) == Float64 && isnan(v) df[row,col] = NA end end end df end Am looking for an ideomatic and concise way. 2016-05-14 18:58 GMT+10:00 Tamas Papp <tkp...@gmail.com>: > Also, in the meantime, you can use something like > > function nan2na(df) > for c in eachcol(df) > nans = find(x->isa(x,AbstractFloat) && isnan(x),c[2]) > df[nans,c[1]] = NA > end > df > end > > nan2na(mlmf) > > to convert NaNs to NAs. > > Best, > > Tamas > > On Sat, May 14 2016, Milan Bouchet-Valat wrote: > > > Le samedi 14 mai 2016 à 17:49 +1000, Андрей Логунов a écrit: > >> using RDatasets, DataFrames > >> mlmf = dataset("mlmRev","Gcsemv"); > >> > >> Produces > >> > >> │ 1 │ "20920" │ "16" │ "M" │ 23.0 │ NaN │ > >> │ 2 │ "20920" │ "25" │ "F" │ NaN │ 71.2 │ > >> │ 3 │ "20920" │ "27" │ "F" │ 39.0 │ 76.8 │ > >> │ 4 │ "20920" │ "31" │ "F" │ 36.0 │ 87.9 │ > >> │ 5 │ "20920" │ "42" │ "M" │ 16.0 │ 44.4 │ > >> │ 6 │ "20920" │ "62" │ "F" │ 36.0 │ NaN │ > >> │ 7 │ "20920" │ "101" │ "F" │ 49.0 │ 89.8 │ > >> │ 8 │ "20920" │ "113" │ "M" │ 25.0 │ 17.5 │ > >> │ 9 │ "20920" │ "146" │ "M" │ NaN │ 32.4 │ > >> │ 10 │ "22520" │ "1" │ "F" │ 48.0 │ 84.2 │ > >> │ 11 │ "22520" │ "7" │ "M" │ 46.0 │ 66.6 │ > >> > >> > >> Should be NAs but here we have NaNs > > Thanks for the reproducible example. Please file an issue on GitHub > > against RDatasets. > > > > > > Regards > > > >> 2016-05-14 17:22 GMT+10:00 Tamas Papp <tkp...@gmail.com>: > >> > Again: please provide a self-contained example. > >> > > >> > On Sat, May 14 2016, Андрей Логунов wrote: > >> > > >> > > The misuse of the word is all mine. > >> > > But the problem persists. RDatasets in Win10 produce NaN-values > >> > for > >> > > unvailable values (NAs) as compared to Unices. > >> > > So the funcs dropna() and complete_cases() 'do not work' as > >> > needed? no > >> > > filtering done. As I understand Complete_cases() uses a bitarray. > >> > But is > >> > > there a shortcut? > >> > > > >> > > > >> > > > >> > > суббота, 14 мая 2016 г., 16:26:01 UTC+10 пользователь Tamas Papp > >> > написал: > >> > >> > >> > >> On Sat, May 14 2016, Андрей Логунов wrote: > >> > >> > >> > >> > To add, fiddling with array comprehensions as per the problem > >> > with NaNs > >> > >> > found a buggy thing. > >> > >> > The following code does not work: > >> > >> > > >> > >> > [x for x in filter(!isnan, convert(Array,dataframe[:fld]))] > >> > >> > >> > >> This is not a bug. ! does not operate on functions, only on > >> > concrete > >> > >> values (Bitarray, Bool, etc). > >> > >> > >> > >> Also, even if you find a bug, "does not work" is unlikely to get > >> > you any > >> > >> help without an error message and preferably a self-contained > >> > example. > >> > >> > >> > >> Best, > >> > >> > >> > >> Tamas > >> > >> > >> > > >> > > >