Which is the recommended way to access Dataframe columns in Julia: Using df[:col] or df.col? For example, in Pandas Dataframe, the recommended way is using the bracket notation for performance as well as other reasons as discussed here: Speed difference between bracket notation and dot notation for accessing columns in pandas.
So, is there a similar recommendation for using bracket notation over the dot notation for Dataframes in Julia, either for performance or otherwise? Or are both equally good?
They are equally good, and normally df.col is used. There are two cases when you need to use the other style:
df[Symbol("Some column name with spaces")]col does not exist in df the syntax df.col .= 1 will not work while df[:col] .= 1 will create a new column.Note that df.col notation is handy as if you write df. and press <tab> in REPL or Jupyter Notebook you will get a list of column names.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With