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

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?


Find answers to all your questions here:


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


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 !.


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!