3

Do you know where I can find max() min() functions for DataFrames in Julia? The data frame includes X,Y,Z coordinates. I want to find the highest value for the point with the highest x & y coordinate. Or should I do it with a "for loop" and a "if condition"?

1.EDIT: For example I have different points with X,Y,Z coordinates and I actually want to find the point with the highest X coordinate. I have done that with sorting the Data Frame. But how about finding the point with the highest X and Y coordinate? In combination... from all other points in the data.

2.EDIT: Pareto works great in that case, maybe it was my wrong explanation. How to use that principle to get all particle around the circle? The goal is to gain all related particles --> closed circle, of course it's only a approximation to a circle. Example conditions to reach the circle:

  1. Point: X & Y maximum
  2. Point: X & Y minimum
  3. Point: X maximum & Y maximum/2
  4. Point: X maximum/2 & Y maximum
  5. ...

Particle Plot

Thank you!

Tom
  • 100
  • 6
  • Can you give an example what you want as "the highest value for in one row with the highest x && y coordinate" is not fully clear for me". In general - no matter what you want should be easily doable with DataFrames.jl, so once I understand what you need I can give you the code. – Bogumił Kamiński Oct 21 '20 at 17:45
  • I edited the post! – Tom Oct 21 '20 at 18:41
  • OK. I assume you want to find a [Pareto frontier](https://en.wikipedia.org/wiki/Pareto_efficiency) of your data? In this case you have the algorithms for solving this problem described in the linked Wikipedia page. – Bogumił Kamiński Oct 21 '20 at 19:57
  • Uh that's fantastic! Didn't heard about that. Thank you! Do you know any resources in Julia about that? – Tom Oct 21 '20 at 21:36
  • This can be done in several ways. One of them is https://github.com/anriseth/MultiJuMP.jl, but I am not 100% sure it will fit your use case (in simple scenarios it is easy enough to sort and filter; I will add an example as a solution so that you have something to start with). – Bogumił Kamiński Oct 22 '20 at 05:28
  • Another option: https://github.com/cossio/ParetoEfficiency.jl – a06e Feb 01 '22 at 21:11

1 Answers1

3

First generate the data:

julia> using DataFrames, PyPlot

julia> df = DataFrame(x=rand(1000), y=rand(1000));

julia> filter!(sdf -> sdf.x^2+sdf.y^2 < 1, df);

julia> scatter(df.x, df.y);

to get something like: enter image description here

Now you establish a Pareto front:

julia> sort!(df, rev=true);

julia> pareto = df[1:1, :];

julia> foreach(row -> row.y > pareto.y[end] && push!(pareto, row), eachrow(df));

julia> scatter(pareto.x, pareto.y);

to get: enter image description here

(you have the points belonging to the Pareto front plotted in orange)

Bogumił Kamiński
  • 66,844
  • 3
  • 80
  • 107
  • Yes that's amazing. I put some more information above. – Tom Oct 22 '20 at 08:47
  • Again - "How to use that principle to get all particle around the circle with the same conditions?" is not fully clear for me? Is this possible that you specify what you need to get using mathematical formulas? – Bogumił Kamiński Oct 22 '20 at 08:57
  • I understand, look above. In your example it would be to get all points which are on the outside position of your plot. Does it help? – Tom Oct 22 '20 at 09:42
  • 1
    Then it is yet another thing that you want - it is a convex hull of your set of points. See here: https://en.wikipedia.org/wiki/Convex_hull. The algorithms are described here https://en.wikipedia.org/wiki/Convex_hull_algorithms. Here you have a list of packages that are related https://github.com/JuliaPolyhedra. If you have problems with implementing them I think it is best if you ask another question for it. – Bogumił Kamiński Oct 22 '20 at 10:49
  • Is it possible in the future, after I have used this method, to cut it for example in the middle to get a cut edge in 2D view? Or am I on the wrong track here? – Tom Nov 09 '20 at 10:46
  • I am not sure what you would want exactly. Probably it is easiest if you post a new question showing input data (not plot, but raw data) and expected output data. – Bogumił Kamiński Nov 09 '20 at 11:44
  • Are you aware of any implementation in Julia of algorithm to compute the Pareto front of a finite set of points? – a06e Nov 23 '21 at 14:38
  • https://github.com/anriseth/MultiJuMP.jl, but it depends on what you need – Bogumił Kamiński Nov 23 '21 at 15:06