Dear Python Community,

I am relatively new to the application of functions and tend to stick to more basic UDF. So your help is greatly appreciated here (I want to use this as an opportunity to learn).

Part 1:

I need to write a function which first sorts a dataframe’s values based on date column in ascending order. The dataframe at present has just 7000 rows (as I have filtered to one month of data for this test, to make it easier).

I then need to loop over the data to find and then create a flag in the dataframe for the first 30% of rows (this will be the first 2100 rows in this case).

I would like to do this looping process to flag the rows in the 40%, 50%, 60%, 70% brackets, creating flags for each of them.

Part 2:

The problem then gets a bit more tricky in that the initial filter needs to be removed so that I can then apply to every month within the dataframe (I am less concerned about this right now, but general ideas would be welcomed).

Thanks in advance for any help

kind regards

James