Delete certain rows of a matrix in julia

I am learning julia in a university course and I have to do an assigment but I don’t know how to preprocess the data. Hi have a matrix with patterns distributed in rows. Its dimension is 1521×4. The first attribute take values from 0 to 4 and I want to delete patterns (rows) whose first… Read More Delete certain rows of a matrix in julia

How do I graph a line in Julia with an arrow on both sides?

Here is my code: using MTH229 using Plots f(x)=x theme(:dark) plot(f,-5,5,linewidth=5,c=:hotpink,legend=false,arrow=true) Here is a picture of the output: plot How do I get the arrow to appear on both ends of the line instead of just one? >Solution : It’s a bit of a hacky solution, but for the example in the question: plot!([-4.99,-5],[f(-4.99), f(-5)],… Read More How do I graph a line in Julia with an arrow on both sides?

How to purge missing values from a DataFrame in Julia?

After reading the context, if you felt the title could be enhanced to fit the question and you had an idea, feel free to update it. Suppose I have the following DataFrame: using DataFrames df = DataFrame( g=["a","b","a","c",missing,missing,missing,missing], a=[1,2,3,4,missing,missing,missing,missing], Column1=[missing,missing,missing,missing,false,false,false,true], Column2=[missing,missing,missing,missing,false,true,true,true], Column3=[missing,missing,missing,missing,true,true,false,false], ) # 8×5 DataFrame # Row │ g a Column1 Column2 Column3 #… Read More How to purge missing values from a DataFrame in Julia?

"ERROR: ArgumentError: Table returned but a single output column was expected" in transform! dataframes

I want to perform a simple One-Hot encoding by utilizing DataFrames.jl‘s transform! but I’m unsuccessful. I use the following DataFrame: using DataFrames df = DataFrame( color = ["red", "green", "blue"], x = [1, 2, 3] ) # 3×2 DataFrame # Row │ color x # │ String Int64 # ─────┼─────────────── # 1 │ red 1… Read More "ERROR: ArgumentError: Table returned but a single output column was expected" in transform! dataframes

How to calculate Euclidean distance between a tuple and each tuple in a Vector using map in Julia?

I want to calculate the Euclidean distance between a tuple and each tuple within a Vector in Julia using the map function, like below (but I get two values instead of three): julia> tups = [ (1, 3), (11, 2), (0, 1) ]; julia> map((x, y) -> √(sum((x.-y).^2)), tups, (3, 3)) 2-element Vector{Float64}: 2.0 8.06225774829855… Read More How to calculate Euclidean distance between a tuple and each tuple in a Vector using map in Julia?