given in a data frame with numerical values ββin a certain column, I want to randomly delete a certain percentage of rows for which the value in this particular column is in a certain range.
For example, for the following data frame:
df = pd.DataFrame({'col1': [1,2,3,4,5,6,7,8,9,10]}) df col1 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10
2/5 lines, where col1 is less than 6, should be deleted randomly.
What is the most concise way to do this?
source share