How to globally change a data frame inside for loop?

Yao_Vang
Thu, 25 May 2023 07:03:45 +0000
Data

Hi there!

How to apply changes in for loops to be kept outside of for loop too?
I have a dataframe that is read inside a for loop via a function and and after bunch of computation, I apply a filter command over it and hope to have the changed dataframe for the next iterations of for loop. But the dataframe df does not change. How can I ask julia to keep changes and read the chnaged df at each iteration?

for  i in I
      # read df
      # do some computation...
     elements= find_removeable_indices(x) # this function returns some indices that we want to remove from df later
    # do some other computation...
    filter!(row -> (row.Index ∉ elements) && row.Price >= current_Price + shift , df)  # df is the original dataframe with 1000 rows and 50 columns. One of the columns is `index`, the other is `Price` and shift is a constant
end

5 posts - 4 participants