-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix NaNtoMissing #116
base: master
Are you sure you want to change the base?
fix NaNtoMissing #116
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
# REVIEW THIS IN LIGHT OF NEW DATAFRAMES | ||
# ======================================== | ||
|
||
import Base: isnan | ||
import DataFrames: DataFrame, ncol, convert | ||
|
||
|
||
|
@@ -269,16 +268,12 @@ function expand_categoricals!(df::DataFrame,categoricals::Array) | |
return expand_categoricals!(df, categoricalidxs) | ||
end | ||
|
||
# convert NaNs to NAs | ||
# isnan(x::NAtype) = false | ||
isnan(x::AbstractString) = false | ||
isnan(x::Union{T, Nothing}) where T = isnan(x.value) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was a bad find and replace from a previous PR that replaced |
||
|
||
# same functionality as above. | ||
function NaNs_to_Missing!(df::DataFrame) | ||
m,n = size(df) | ||
for j=1:n | ||
df[!,j] = [ismissing(df[i,j]) || isnan(df[i,j]) ? missing : value for (i,value) in enumerate(df[:,j])]; | ||
df[!,j] = [(value isa Number && isnan(value)) ? missing : value for value in df[!,j]]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is just a bit simpler we only need the |
||
end | ||
return df | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was type-piracy.
Fixed the problem that it was avoiding via adding
isa Number
check below