I have a large Dataframe with the following columns:
The data used as the example here can be found here
import pandas
x = pd.read_csv('example1_csv.)
x.head()
ID Year Y
22445 1991 40.0
29925 1991 43.333332
76165 1991 403.0
223725 1991 65.0
280165 1991 690.5312
I want to change the numbers in the column Y to the categories low, mid, high, where each category is specific to a range of numbers in Y:
Lowreplaces any number within the range of-3000to600inY.Midreplaces any number within the range of601to1500inY.Highreplaces any number within the range of1501to17000inY.
For example, if an ID has a Y value between -3000 and 600 then that ID will have the numeric value in Y replaced as Low.
How does one make these replacements? I have tried several ways but have run into str and int type errors every time. The data file used in this question is in the Github link above. Many thanks in advance for the help.