# New To Julia: How to get 2 values from dataset

**URL:** <https://discourse.julialang.org/t/new-to-julia-how-to-get-2-values-from-dataset/66553>\
**Category:** New to Julia\
**Tags:** question, plotting\
**Created:** [August 17, 2021, 2:41pm UTC](https://discourse.julialang.org/t/new-to-julia-how-to-get-2-values-from-dataset/66553 "2021-08-17T14:41:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![atplf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/atplf/32/28254_2.png) [@atplf](https://discourse.julialang.org/u/atplf)\
**Post date:** [August 17, 2021, 2:41pm UTC](https://discourse.julialang.org/t/new-to-julia-how-to-get-2-values-from-dataset/66553/1 "2021-08-17T14:41:41Z")

</div>

I have df like this: ![Capture](https://global.discourse-cdn.com/julialang/original/3X/1/9/191bba64917636f155e142421c9342d4433b4c22.png)  
How can I get values from “\<=50K” and “\>50K” of “19-30”, “41-50”. And then i want to make a group bar from 2 values. Anyone can answer me this question. Thank you so much

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [August 17, 2021, 2:53pm UTC](https://discourse.julialang.org/t/new-to-julia-how-to-get-2-values-from-dataset/66553/2 "2021-08-17T14:53:04Z")

</div>

I would recommend you to read through part of DataFrames’ manual: [Working with DataFrames · DataFrames.jl](https://dataframes.juliadata.org/latest/man/working_with_dataframes/)

Also, it will be much easier for others to help you if you have run-able code that can produce toy dataframe, as well as the expect output.

My guess is this is what you’re looking for:

```julia
julia> df
10×3 DataFrame
 Row │ income agerange count 
     │ Float64 Int64 Int64 
─────┼────────────────────────────
   1 │ 0.672059 1 44
   2 │ 0.0819106 2 91
   3 │ 0.148481 3 50
   4 │ 0.540397 4 74
   5 │ 0.209084 5 24
   6 │ 0.497517 6 61
   7 │ 0.355426 7 37
   8 │ 0.834293 8 90
   9 │ 0.258418 9 8
  10 │ 0.0474276 10 37

julia> df[df.agerange .∈ Ref((1,8)), :]
2×3 DataFrame
 Row │ income agerange count 
     │ Float64 Int64 Int64 
─────┼───────────────────────────
   1 │ 0.672059 1 44
   2 │ 0.834293 8 90

julia> sum(df[df.agerange .∈ Ref((1,8)), :count])
134

```

---

<div class="post-metadata">

**Author:** ![atplf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/atplf/32/28254_2.png) [@atplf](https://discourse.julialang.org/u/atplf)\
**Post date:** [August 17, 2021, 3:12pm UTC](https://discourse.julialang.org/t/new-to-julia-how-to-get-2-values-from-dataset/66553/3 "2021-08-17T15:12:18Z")

</div>

thank you so much, in this “income” column, it has 2 kind of values: \<=50K, 50K. I just want to take “count” values from them, and these values ∈ same “agerange” values.  
Example: agerange : 19-31, Income \>50K, **count 1391** and  
agerange : 19-31, Income \<=50K, **count 8945**.  
I want to get these values ​​in general, do you have any  
recipe for this  
Anyway your code help me so much, thanks

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [August 17, 2021, 3:17pm UTC](https://discourse.julialang.org/t/new-to-julia-how-to-get-2-values-from-dataset/66553/4 "2021-08-17T15:17:06Z")

</div>

you just need:

```julia
df[df.agerange .== "19-31", :count]

```

, if you don’t care about the Income column.

Again, I highly encourage you to read the manual because these basics mechanism you need to understand if you want to do anything.
