JuliaAcademy / DataScience

Data Science in Julia course for JuliaAcademy.com, taught by Huda Nassar
https://juliaacademy.com/p/julia-for-data-science
MIT License
488 stars 256 forks source link

findall( ) error fixed : " LoadError: TypeError: non-boolean (Int64) used in boolean context " #31

Closed greatti closed 3 years ago

greatti commented 3 years ago

On Data class we have a situation where we need to find the number of languages created in a certain year using 'how_many_year_count' on P, but the way it is passed for us on the videos are not updated, so reading the documentation i found how to fix it:

function how_many_per_year(P, year::Int)
    year_count = length(findall(x -> x .== year, P[:, 1])) 
    return year_count
end

Thats because findall( ) documentation says that we need to pass the first parameter as a condition to what it should add to the array to count. ( https://docs.julialang.org/en/v1/base/arrays/#Base.findall-Tuple{Function,%20Any} )

logankilpatrick commented 3 years ago

This has been resolved and the notebooks are now working. Please let me know if you still think something is missing.