Home > OS >  Understanding with julia dataframes indexing
Understanding with julia dataframes indexing

Time:11-25

I am learning julia and i've just found this line:

if(any(mach_df[start_slot:(start_slot   task_setup_time), Symbol(machine)].== 0))

What does it mean?, I know any is a function that returns true if every value of the parameter is true but I just can't understand what is inside the brakets.

Regards

CodePudding user response:

Let us work inside out:

  • mach_df[start_slot:(start_slot task_setup_time), Symbol(machine)] selects you rows from the range start_slot:(start_slot task_setup_time) and column named Symbol(machine) (Symbol is most likely not needed, but I would need to see your source code to tell you exacly); as a result you get a vector.
  • mach_df[start_slot:(start_slot task_setup_time), Symbol(machine)] .== 0 gives you another vector that has true if the value in the LHS vector is 0.
  • the any part will return true if any of the values in the vector produced above is true.

A more advanced (and efficient) way to write it would be:

any(==(0), @view mach_df[start_slot:(start_slot   task_setup_time), Symbol(machine)])

but I am not sure if you need performance in your use case.

  • Related