Manipulate row values based on lists

i have actually a problem and I do not know how to solve it.

I have two lists, which have always the same lengths:

max_values = [333,30,10]
min_values = [30,10,0]

every index of the lists represents the cluster number of a range of the max and the min values, so:

Index/Cluster 0: 0-10
Index/Cluster 1: 10-30
Index/Cluster 2: 30-333

Furthermore I have one dataframe as follows:


Within the df, I have a column called "AVG_MPH_AREA" It should be checked between which cluster range the value is. After the "Cluster" column should be set to the correct index of the list. The old values should be dropped.

In this case it's a list of 3 clusters, but it could also be more or less...

Any idea how to switch that or with which functions?

Read more here:

Content Attribution

This content was originally published by dgho at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: