# 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

# what does numpy.vectorize(lambda x:1 – x^3) do?

I’m new to python and also to numpy package. I was wondering what does this specific line really do. a = numpy.vectorize(lambda x:1 – x^3) I’ve searched about vectorize function but didn’t really get what it does. I’m familiar with julia if there is any instance in julia that does what this line does I… Read More what does numpy.vectorize(lambda x:1 – x^3) do?

# 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 can I sum arrays row-wise in Julia?

Suppose that I have a 2×2 array of the form: [a, b c, d] Here a, b, c and d are numbers. How can I calculate the column-wise sum in Julia? The result should be the column vector: [a + b c + d]. >Solution : Assume your data is mat = [11 12; 21… Read More How can I sum arrays row-wise in Julia?

# 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?

# Julia: How to make a matrix in for loop

I’m a newbie to Julia. Before then, I used Matlab. For the Matlab case, I wrote commands to make the matrix in the for loop, as follows: for i=1:1:100; k(i,:)=i.^2; end I typed the same commands in Julia, but it didn’t work. Furthermore, I tried other commands as follows: n=100; k = Array{Int64, n}; for… Read More Julia: How to make a matrix in for loop

# "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

# Julia dictionaries

Is there a function to get a list of all the dictionaries I am using in a Julia session? I am trying to find the value of a key inside a dictionary, but cant seem to find the dictionary and wanted to make sure I have it. >Solution : I assume that you want to… Read More Julia dictionaries

# Index array with vector of tuples

I have a vector of tuples, where each tuple represents a position in a 2d array. I also have a 2d array of values For example: # create a vector of tuples tupl1 = ((1,1), (2,3), (1,2), (3,1)) # create a 2d array of values m1 = zeros(Int, (3,3)) m1[1:4] .= 1 I want to… Read More Index array with vector of tuples

# 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?