# How to format data for an assignment problem

**URL:** <https://discourse.julialang.org/t/how-to-format-data-for-an-assignment-problem/50794>\
**Category:** New to Julia\
**Created:** [November 26, 2020, 6:05am UTC](https://discourse.julialang.org/t/how-to-format-data-for-an-assignment-problem/50794 "2020-11-26T06:05:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![armitxe1302](https://avatars.discourse-cdn.com/v4/letter/a/6bbea6/32.png) [@armitxe1302](https://discourse.julialang.org/u/armitxe1302)\
**Post date:** [November 26, 2020, 6:05am UTC](https://discourse.julialang.org/t/how-to-format-data-for-an-assignment-problem/50794/1 "2020-11-26T06:05:07Z")

</div>

Hi, I’m new to Julia and programming and general . I’m working on an assigment problem and I’m having some trouble working with DataFrames. I’m trying to create a new dataframe that consist of 2 columns from another dataframe. One colum is going to transform into rows and the other one is going to be the columns of the new dataframe. Something similar to a pivot table on excel. Then I’d like to assign the quotient of 2 colums to the correspondant row, column set. What would be the best way to do this?  
this picture might represent my idea better:

 ![WhatsApp Image 2020-11-26 at 00.28.38](https://global.discourse-cdn.com/julialang/original/3X/9/a/9a67a96249ac4998aa18db6ba2a41d3e29613a23.jpeg)

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [November 26, 2020, 7:37am UTC](https://discourse.julialang.org/t/how-to-format-data-for-an-assignment-problem/50794/2 "2020-11-26T07:37:09Z")

</div>

First you can do `df2 = select(df, [:col1, :col2, :col5])` to get a dataframe with the three columns you want (just calculate the division column before doing the pivoting). Then you can use `df3 = unstack(df2, :col1, :col2, :col5)` which should lead to the pivoted version you wanted if I understood correctly.
