I have my dataframe like below:
+--------------+--------------+----+-----+-------+
| x1 | x2 | km | gmm | class |
+--------------+--------------+----+-----+-------+
| 180.9863129 | -0.266379416 | 24 | 19 | T |
| 52.20132828 | 28.93587875 | 16 | 14 | I |
| -17.17127419 | 29.97013283 | 17 | 16 | D |
| 37.28710938 | -69.96691132 | 3 | 6 | N |
| -132.2395782 | 27.02541733 | 15 | 18 | G |
| -12.52811623 | -87.90951538 | 22 | 5 | S |
这些类别基本上是字母表(A到Z)。但是,我希望输出像A=1,B=2... Z= 26。
现在,对于普通的Python列表,可以像这样转换它们:ord(c.lower()) - ord('a')) % 9) + 1
然而,在数据框中如何做到这一点呢?