I have a dataframe called clients
that has 5000+ rows with the following:
ID Ordered Days
1 101565 131
2 202546 122
3 459863 78
4 328453 327
5 458975 -27
I'm trying to create a loop that looks at the numbers of days and replace them with a new columns if it does meet the days critetaria based on the following:
Days NEW_COLUMNS
0-119 0-3 Months
120-209 4-6 Months
210-299 7-9 Months
300+ 10+ Months
-280 to -196 Reach out clients
-195 to -104 Send promotion
-103 to -1 Close case
< -280 Plan
I have the following code but hasn't worked so far:
if(days <-280)(NEW_COLUMNS ="plan")
else if (days>-280 && days <-196)(NEW_COLUMNS=" Reach out clients";)
else if (days>-195 && days<-104)(NEW_COLUMNS =" Send promotion";)
else if (days>-103 && days <-1)(NEW_COLUMNS="Close case";)
else if(days> 0 && days <119)(NEW_COLUMNS="0-3 Months";)
else if(days > 120 && days <209)(NEW_COLUMNS="4-6 Mos";)
else if(days > 210 && day s<299)(NEW_COLUMNS="7-9 Mos";)
else if(days > 300)(NEW_COLUMNS="10+ Mos";)
Eventually I want a table that looks like this:
ID Ordered Days New_Columns
1 101565 131 4-6 Months
2 202546 122 4-6 Months
3 459863 78 0-3 Months
4 328453 327 10+ Months
5 458975 -27 Close case