I got a table with some columns in it and one column got values going from 0 to 400. Let's call it column x.
Now i want to group these information in the table based on the values. I want a new column "valuerange" that says in which range the value of column x is. For example the value of the column x is at a specific row 120, therefor i want in the new column "100-150".
Maybe i need to mention that the table is a large dataframe with 210k rows.
I allready tried myself but i can't get to the expected result since i'm new to python and just used to java.
Here is some code i tried:
df1 = df['valuerange'] = ['0-50' if p<=50 '51-100' elif p<=100 '101-150' elif p<=150
'151-200' elif p<=200 '201-250' elif p<=250 '251-300' elif p<=300
'301-350' elif p<=350 '351-400' elif p<=400 for p in df.x]