bkamins / Julia-DataFrames-Tutorial

A tutorial on Julia DataFrames package
MIT License
531 stars 119 forks source link

coalesce example doesn't work #13

Open lewisl opened 5 years ago

lewisl commented 5 years ago

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.

bkamins commented 5 years ago

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.