Julia-DataFrames-Tutorial icon indicating copy to clipboard operation
Julia-DataFrames-Tutorial copied to clipboard

coalesce example doesn't work

Open lewisl opened this issue 6 years ago • 1 comments

coalesce no longer works as you describe. It must returns the first item that is missing. You must perhaps have left out map(...)?

Sadly, I had to do:

df[ismissing.(df.mycol),:mycol] = "" # or whatever substitute value is appropriate.

lewisl avatar Apr 30 '19 01:04 lewisl

Can you please point which entry in the tutorial is incorrect (I have checked it just now and did not find the error you point out).

The operation you indicate is typically done as:

replace!(df.mycol,missing=>"")

if substitute value has the type that is subtype of eltype(df.mycol) or

df.mycol = coalesce.(df.mycol, "")

otherwise (as you have to replace the vector in the DataFrame by a new vector).

I will update the tutorial to make it more explicit.

bkamins avatar Apr 30 '19 06:04 bkamins