Skip to content

Instantly share code, notes, and snippets.

@AnupJoseph
Created November 6, 2022 07:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AnupJoseph/addccb3f1297832bf035107289e6e1d8 to your computer and use it in GitHub Desktop.
Save AnupJoseph/addccb3f1297832bf035107289e6e1d8 to your computer and use it in GitHub Desktop.
function build_median_income(x)
x =strip(x,['>','\$','<'])
if occursin("-",x)
low,high = split(x,"-")
low = parse(Int,replace(low,","=>""))
high = parse(Int,replace(high,","=>""))
return (low+high)/2
else
x = parse(Int,replace(x,","=>""))
return x==1000000 ? x : x/2
end
end
function build_median_age(x)
if x == "I have never written code"
return 0
elseif x == "< 1 years"
return 0.5
elseif x == "20+ years"
return 25
else
x = replace(x,"years"=>""," "=>"")
low,high = split(x,"-")
low,high = parse(Int,low),parse(Int,high)
return (low+high)/2
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment