Вам нужно это
import string
d = dict(enumerate(list(string.ascii_uppercase))) # will give 26 unique values
df['S_I']=df.groupby(['s_lat','s_lng','d_lat','d_lng'], sort = False).ngroup().map(d)
Если может быть более 26 уникальных групп, вы можете использовать следующий код для создания списка d
from itertools import product
combs= [''.join(i) for i in product(string.ascii_uppercase, repeat = 2)]
d=dict(enumerate(combs))
#Change the number for 'repeat' as needed.
with 2, you get 676 unique combinations like "'AA','AB','AC'..."
with 3, you get 17576 unique combinations like "'AAA','AAB','AAC'..."
Вывод
Id s_lat s_lng d_lat d_lng TT T Esti2 Est1 time_diff diff Cluster S_I
0 67607 63.42 10.387 63.425 10.441 10.200000 4.33 11 4.4 -0.800000 -0.07 0 A
1 70720 63.42 10.387 63.425 10.441 9.033333 4.36 11 4.4 -1.966667 -0.04 0 A
2 68394 63.42 10.387 63.436 10.399 15.183333 2.66 10 2.7 5.183333 -0.04 0 B
3 67340 63.42 10.387 63.436 10.399 8.916667 2.44 10 2.7 -1.083333 -0.26 0 B
4 72363 63.42 10.387 63.436 10.399 9.916667 2.47 10 2.7 -0.083333 -0.23 0 B
5 70401 63.42 10.387 63.436 10.399 7.850000 2.67 10 2.7 -2.150000 -0.03 0 B
6 70695 63.42 10.387 63.436 10.399 11.616667 3.24 10 2.7 1.616667 0.54 0 B
7 69698 63.42 10.387 63.436 10.399 8.916667 2.47 10 2.7 -1.083333 -0.23 0 B
8 70793 63.42 10.387 63.436 10.399 11.850000 2.52 10 2.7 1.850000 -0.18 0 B
9 67150 63.42 10.387 63.411 10.402 4.016667 1.68 6 1.7 -1.983333 -0.02 0 C
10 69934 63.42 10.387 63.411 10.402 4.566667 1.69 6 1.7 -1.433333 -0.01 0 C