# Accessing predefined array of DataFrame?

**URL:** https://discourse.julialang.org/t/accessing-predefined-array-of-dataframe/47981
**Category:** New to Julia
**Created:** [October 8, 2020, 11:58am UTC](https://discourse.julialang.org/t/accessing-predefined-array-of-dataframe/47981 "2020-10-08T11:58:00Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)
#### Post date: [October 8, 2020, 11:58am UTC](https://discourse.julialang.org/t/accessing-predefined-array-of-dataframe/47981/1 "2020-10-08T11:58:00Z")

</div>

Hello!

Suppose I have a dataframe as such:

```julia
 df1
10×3 DataFrame
│ Row │ A │ B │ C │
│ │ Int64 │ String │ Float64 │
├─────┼───────┼────────┼──────────┤
│ 1 │ 1 │ z │ 0.907622 │
│ 2 │ 2 │ x │ 0.547183 │
│ 3 │ 3 │ z │ 0.4511 │
│ 4 │ 4 │ y │ 0.645394 │
│ 5 │ 5 │ x │ 0.697474 │
│ 6 │ 6 │ z │ 0.277188 │
│ 7 │ 7 │ z │ 0.346081 │
│ 8 │ 8 │ x │ 0.516901 │
│ 9 │ 9 │ y │ 0.738648 │
│ 10 │ 10 │ x │ 0.663217 │

```

This dataframe exists inside one of my functions. Then I want to pass a variable, to denote which column I want to use, so for example;

```julia
plot_df(A)

```

Where it should plot my loaded dataframe column A. How do I do this properly? I am aware one when working with Dataframes can do, “df1.A”, but I can’t get this I described to work.

Kind regards

---

<div class="post-metadata">

### Author: ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)
#### Post date: [October 8, 2020, 12:16pm UTC](https://discourse.julialang.org/t/accessing-predefined-array-of-dataframe/47981/2 "2020-10-08T12:16:06Z")

</div>

You could do:

```julia
plot_df(x, df) = plot(df[!, x])

```

but I guess this isn’t really a win over just doing `plot(df[!, x])` directly?

---

<div class="post-metadata">

### Author: ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)
#### Post date: [October 8, 2020, 12:18pm UTC](https://discourse.julialang.org/t/accessing-predefined-array-of-dataframe/47981/3 "2020-10-08T12:18:12Z")

</div>

Nono, that is great, exactly what I wanted. Thanks!
