Minimum and maximum by column in a datafram


I’m a beginner with Julia.

I’ve got a dataframe called data that i converted in an array of floats.

data_temp = deepcopy(data)

Now, i want to extract from the array df (10 rows and 5 columns)

  • a vector{Float64} including the smallest values for the 3 first columns and the highest values for the 2 last columns
  • a vector{Float64} including the highest values for the 3 first columns and the smallest values for the 2 last columns

I don’t know how to do it.

Thanks in advance for your help

You don’t need a Matrix at all:

vec_1 = [minimum.(eachcol(df[!, 1:3]); maximum.(eachcol(df[!, 4:5]))]

I’ve tried:


But it doesn’t work.
Why ?


gives a 1x3 matrix, which is not a vector. Maybe you want to collect that output so you can vcat them.

The error is pretty self-explanatory imo. Make sure you read the error messages and debug piece by piece.

ok but how can i concatenate the 1x3 matrix and the 1x2 matrix ?


doesn’t work

The vcat here is exactly the same as ; above.

You can use hcat or, as I wrote above, use collect

Please read the responses carefully.

You are right !
Sorry…and thanks a lot !