我有一个数据帧,我想切片该列的所有值,但我不知道如何做
我的数据帧
+-------------+------+
| studentID|gender|
+-------------+------+
|1901000200 | M|
|1901000500 | M|
|1901000500 | M|
|1901000500 | M|
|1901000500 | M|
+-------------+------+
我已将studentID
转换为字符串,但无法从中删除前190个。我想要低于输出
+-------------+------+
| studentID|gender|
+-------------+------+
| 1000200 | M|
| 1000500 | M|
| 1000500 | M|
| 1000500 | M|
| 1000500 | M|
+-------------+------+
我尝试了下面的方法,但它给了我错误
students_data = students_data.withColumn('studentID',F.lit(students_data["studentID"][2:]))
TypeError: startPos and length must be the same type. Got <class 'int'> and <class 'NoneType'>, respectively.
输出:
相关问题 更多 >
编程相关推荐