I use this function:

""" `dropnan_dumb(df::DataFrame, axis=1)`

Returns `df` with all rows that have any `NA` removed """
function dropnan_dumb(df::DataFrame, axis=1)
    @assert axis==1 # TODO
    todrop = fill(false, size(df, 1))
    for col in names(df)
        todrop = todrop | [isna(el) for el in df[col]]
    end
    df[find(~todrop), :]
end



On Thursday, March 17, 2016 at 10:17:36 AM UTC-4, Eugen Neu wrote:
>
>
> Hi,
>
> I am a new julia user. I have a dataset (
> http://www-bcf.usc.edu/~gareth/ISL/Auto.csv) where one column contains 
> NAs. The data can be read using:
>
> Auto = readtable("data/Auto.csv", nastrings = ["?"])
>
> I would like to remove the rows that contain NAs. I found the dropna 
> function. However, this seems to work only for DataArrays not for 
> DataFrames. I also found: 
> http://stackoverflow.com/questions/27844621/how-can-i-delete-all-rows-of-a-dataframe-that-have-an-na-in-a-specific-column
> However, this only works when one specifies the column that contains NAs. 
>
> Is there a function that removes every DataFrame row that includes one or 
> more NAs?
>
> Kind regards,
> Eugen
>

Reply via email to