# Different of df\[!, :name\] and df\[:, :name\]

**URL:** <https://discourse.julialang.org/t/different-of-df-name-and-df-name/98727>\
**Category:** New to Julia\
**Tags:** dataframes\
**Created:** [May 12, 2023, 8:53am UTC](https://discourse.julialang.org/t/different-of-df-name-and-df-name/98727 "2023-05-12T08:53:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![June](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/june/32/49708_2.png) [@June](https://discourse.julialang.org/u/June)\
**Post date:** [May 12, 2023, 8:53am UTC](https://discourse.julialang.org/t/different-of-df-name-and-df-name/98727/1 "2023-05-12T08:53:49Z")

</div>

Dear Julia Users,

I’m learning Julia with DataFrames.jl and see this one example df[!, :name] to get all column elements under :name, which shows the same result as df[:, :name]. My question is:

1. What does the “!” mean in this context?
2. What is the difference between these two?

Thanks!

---

<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:** [May 12, 2023, 8:56am UTC](https://discourse.julialang.org/t/different-of-df-name-and-df-name/98727/2 "2023-05-12T08:56:10Z")

</div>

Find answers to all your questions here:

[https://dataframes.juliadata.org/stable/lib/indexing/](https://dataframes.juliadata.org/stable/lib/indexing/)

or in write-up form here (especially rules 5 and 6):

> **[DataFrames.jl indexing rules](https://bkamins.github.io/julialang/2022/10/28/indexing.html)**
>
> Introduction

---

<div class="post-metadata">

**Author:** ![bkamins](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bkamins/32/208538_2.png) [@bkamins](https://discourse.julialang.org/u/bkamins)\
**Post date:** [May 12, 2023, 9:25am UTC](https://discourse.julialang.org/t/different-of-df-name-and-df-name/98727/3 "2023-05-12T09:25:13Z")

</div>

In short: `!` and `:` are the same. The difference is that `:` (safer, slower) copies data and `!` does not copy data (more error prone, but faster).

I typically recommend users to use `:` unless they have a reason to use `!`.

---

<div class="post-metadata">

**Author:** ![June](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/june/32/49708_2.png) [@June](https://discourse.julialang.org/u/June)\
**Post date:** [May 12, 2023, 9:27am UTC](https://discourse.julialang.org/t/different-of-df-name-and-df-name/98727/4 "2023-05-12T09:27:40Z")

</div>

That’s exactly what I’m looking for. I thought “!” is an commonly used matrix selector in Julia and forget to check it in DataFrames package. Great thanks!
