Mar-27-2024, 02:42 AM
So Dean was previously kind enough to tell me about vector operations on dataframes instead of iterating through each row using loops and has made my code so much better...
So now I have a situation where I have a dataframe with about 930,000 rows. I need to reduce that dataframe by kicking out select rows, which I plan to do via a boolean indexing.
However, I also have an array with n values inside of it (my test case has 5 values in array, but I need the code to with with n values in array).
For each value in my array, I need to run a function that will output start and stop row numbers of rows that I want to keep in my dataframe.
So the way I know how to do this is to use a loop to run through each value in my array, and based on that get all my starting and ending rows for each time the loop runs through and then use boolean indexing to reduce the dataframe.
However, I was wondering, is there a more elegant way to do this? Or do I just need to loop it? Thanks!
So now I have a situation where I have a dataframe with about 930,000 rows. I need to reduce that dataframe by kicking out select rows, which I plan to do via a boolean indexing.
However, I also have an array with n values inside of it (my test case has 5 values in array, but I need the code to with with n values in array).
For each value in my array, I need to run a function that will output start and stop row numbers of rows that I want to keep in my dataframe.
So the way I know how to do this is to use a loop to run through each value in my array, and based on that get all my starting and ending rows for each time the loop runs through and then use boolean indexing to reduce the dataframe.
However, I was wondering, is there a more elegant way to do this? Or do I just need to loop it? Thanks!