Input dataframe(Sample)
Date Location Value
01-01-2020 Loc1 27.2
02-01-2020 Loc1 41.9
03-01-2020 Loc1 29.8
04-01-2020 Loc1 7.8
05-01-2020 Loc1 44
06-01-2020 Loc1 0.4
07-01-2020 Loc1 0.8
08-01-2020 Loc1 4.1
09-01-2020 Loc1 4
10-01-2020 Loc1 6.2
11-01-2020 Loc1 54.5
12-01-2020 Loc1 24.8
13-01-2020 Loc1 0
.
.
.
.
01-01-2020 Loc2 6
02-01-2020 Loc2 40.2
03-01-2020 Loc2 2.6
04-01-2020 Loc2 10.2
05-01-2020 Loc2 12
06-01-2020 Loc2 3.2
07-01-2020 Loc2 0
08-01-2020 Loc2 2.4
09-01-2020 Loc2 0
10-01-2020 Loc2 1.2
11-01-2020 Loc2 19.2
12-01-2020 Loc2 21.8
13-01-2020 Loc2 13.6
....
I want to add another column 'Rating', populated using the below logic
Rating Condition
1 Less than 150 days of data
2 150 to 200 days
3 200 to 250 days
4 250 to 300 days
5 All 365 days
Suppose Loc1 has data for 180 days, thus a rating of 2 for each row, similarly Loc2 has data for all 360 days and hence a rating of 5. So, the output data will look like
Date Location Value Rating
01-01-2021 Loc1 27.2 2
02-01-2021 Loc1 41.9 2
03-01-2021 Loc1 29.8 2
04-01-2021 Loc1 7.8 2
05-01-2021 Loc1 44 2
06-01-2021 Loc1 0.4 2
07-01-2021 Loc1 0.8 2
08-01-2021 Loc1 4.1 2
09-01-2021 Loc1 4 2
10-01-2021 Loc1 6.2 2
11-01-2021 Loc1 54.5 2
12-01-2021 Loc1 24.8 2
13-01-2021 Loc1 0 2
.
.
.
.
01-01-2021 Loc2 6 5
02-01-2021 Loc2 40.2 5
03-01-2021 Loc2 2.6 5
04-01-2021 Loc2 10.2 5
05-01-2021 Loc2 12 5
06-01-2021 Loc2 3.2 5
07-01-2021 Loc2 0 5
08-01-2021 Loc2 2.4 5
09-01-2021 Loc2 0 5
10-01-2021 Loc2 1.2 5
11-01-2021 Loc2 19.2 5
12-01-2021 Loc2 21.8 5
13-01-2021 Loc2 13.6 5
.
.
Note: Date Column is a datetime obj.
I want to do this for the entire dataframe, how can I achieve this?