Created
November 6, 2022 07:00
-
-
Save AnupJoseph/addccb3f1297832bf035107289e6e1d8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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