What is the difference in purpose between ! and @view for indexing a DataFrame? @bkamins’ indexing blog post says
When extracting the data from a data frame if you use ! no copying of data is made. Instead, you just get a column as it is stored in the source data frame (or an appropriate view if you work with a view of a data frame)
but that seems to be what @view is for so I don’t see why ! is needed.
To give a concrete example when this makes a difference. The type of @view is SubArray (usually), which means that, if you have code that dispatches on type of a vector the logic might be affected (probably not the result, but some optimizations might be disabled).
There is a subtle difference here though in that a[:] makes a copy but df[!, :x] does not. The comparison would be correct for df[:, :x]. In general df[:, :x] behaves exactly like array indexing but df[!, :x] has some different behaviors explained in the blog post.