Thanks! I wasn't looking for inplace, so each_replacena is half of what I 
was looking for. How would you write it? I was surprised that DataFrame's 
constructor didn't accept a dict of Symbol=>DataArray, so I wound up 
writing `out_df = DataFrame()`, then modifying it, but that's ugly.

On Thursday, September 10, 2015 at 12:08:14 AM UTC-4, Alex Ames wrote:
>
> There's also the each_replacena(dataframe[:col], replacement) function, 
> but that only operates on columns and doesn't appear to replace in-place. A 
> straightforward in-place replacement would look something like: 
>
> function replacena!(dframe::DataFrame, replacement::Any)
>   nrows, ncols = size(dframe)
>   for j = 1:ncols; for i = 1:nrows
>     if isna(dframe[i,j]); dframe[i,j] = replacement; end
>     end
>   end
> end
>
> On Wednesday, September 9, 2015 at 1:42:37 PM UTC-5, Cedric St-Jean wrote:
>>
>> Just found the DataFrames.isna() function, so that's solved, only the 
>> iteration question remains.
>>
>> On Wednesday, September 9, 2015 at 2:26:23 PM UTC-4, Cedric St-Jean wrote:
>>>
>>> In 0.3, what's the best way of replacing all NA with a given value (eg. 
>>> 0)? Pandas has df.fillna. I've noticed that
>>>
>>> isnan(DataFrames.NA)
>>>
>>> is undefined and 
>>>
>>> DataFrames.NA == DataFrames.NA
>>>
>>> is NA. The docs say it's a singleton, so I assume that I should use === 
>>> to check if it's NA? Likewise, how should I iterate over all elements? I 
>>> was disappointed that `map(fun, df)` is not defined (is that an omission? 
>>> it's defined for matrices). Should I just go over all columns one by one?
>>>
>>> Cédric
>>>
>>

Reply via email to