# Organize the output of a mathematical model

**URL:** <https://discourse.julialang.org/t/organize-the-output-of-a-mathematical-model/78378>\
**Category:** Optimization (Mathematical)\
**Tags:** dataframes, tables\
**Created:** [March 24, 2022, 10:18am UTC](https://discourse.julialang.org/t/organize-the-output-of-a-mathematical-model/78378 "2022-03-24T10:18:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![haniaitizem](https://avatars.discourse-cdn.com/v4/letter/h/7bcc69/32.png) [@haniaitizem](https://discourse.julialang.org/u/haniaitizem)\
**Post date:** [March 24, 2022, 10:18am UTC](https://discourse.julialang.org/t/organize-the-output-of-a-mathematical-model/78378/1 "2022-03-24T10:18:49Z")

</div>

Hello I have find a matrix q[j,i,k] at the end of my work, it represent the quantity of product k that should be ordered by client i from the plant j , I want to organize this output in a table in the row I find the plants and columns the customers and products to facilitate the interpretation of the results

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [March 24, 2022, 5:53pm UTC](https://discourse.julialang.org/t/organize-the-output-of-a-mathematical-model/78378/2 "2022-03-24T17:53:44Z")

</div>

Hi there!

Since this is your first post, you might want to start by reading: [Please read: make it easier to help you](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/14757)

At the moment this is a little too generic of a question.

If you can post a small reproducible example with the (simplified) code of what you currently have, then people should be able to help, but this might be a good starting point:

```nohighlight
using DataFrames
client, plant, product, amount = [], [], [], []
for j in 1:J
    for i in 1:I
        for k in 1:K
            push!(client, i)
            push!(plant, j)
            push!(product, k)
            push!(amount, q[j, i, k]
        end
    end
end
DataFrame(
    client = client,
    plant = plant,
    product = product,
    amount = amount,
)

```

Here are some other links:

- [Getting started with data and plotting · JuMP](https://jump.dev/JuMP.jl/stable/tutorials/getting_started/getting_started_with_data_and_plotting/)
- [Introduction · DataFrames.jl](https://dataframes.juliadata.org/stable/)

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [March 24, 2022, 6:35pm UTC](https://discourse.julialang.org/t/organize-the-output-of-a-mathematical-model/78378/3 "2022-03-24T18:35:40Z")

</div>

Not sure if understood alright, but FWIW:

```julia
using DataFrames

# INPUT 3D-ARRAY DATA
n1, n2, n3 = 2, 3, 4
q = round.(Int64, 100*rand(1:10, n1, n2, n3))

# CREATE 2D DATAFRAME
ix = Iterators.product(1:n1, 1:n2, 1:n3)
df = rename!(DataFrame(ix), [:client, :plant, :product])
df.quantity = reshape(q, n1*n2*n3)
df

```

---

<div class="post-metadata">

**Author:** ![haniaitizem](https://avatars.discourse-cdn.com/v4/letter/h/7bcc69/32.png) [@haniaitizem](https://discourse.julialang.org/u/haniaitizem)\
**Post date:** [March 26, 2022, 5:26pm UTC](https://discourse.julialang.org/t/organize-the-output-of-a-mathematical-model/78378/4 "2022-03-26T17:26:12Z")

</div>

thank you odow for the remark and the answer  
I tried the code that you gave me and it answers what I was looking for

---

<div class="post-metadata">

**Author:** ![haniaitizem](https://avatars.discourse-cdn.com/v4/letter/h/7bcc69/32.png) [@haniaitizem](https://discourse.julialang.org/u/haniaitizem)\
**Post date:** [March 26, 2022, 5:28pm UTC](https://discourse.julialang.org/t/organize-the-output-of-a-mathematical-model/78378/5 "2022-03-26T17:28:27Z")

</div>

thank you rafael
