我正在应用一个方法,它给出了错误,因为演员没有做好
我如何才能1)以更有效的方式强制转换所有字段,2)仅使用withcolumn一次,然后3)使用数字(而不是字符串)运行方法:
q5 = q4.withColumn("DISTANCE", q4["LOCLAT"].cast(IntegerType()))
q6 = q4.withColumn("DISTANCE", q4["LOCLONG"].cast(IntegerType()))
q7 = q4.withColumn("DISTANCE", q4["LOCLAT2"].cast(IntegerType()))
q8 = q4.withColumn("DISTANCE", q4["LOCLONG2"].cast(IntegerType()))
q9 = (q4.withColumn('distance', haversine('LOCLONG', 'LOCLAT', 'LOCLONG2', 'LOCLAT2')))
谢谢!!
1条答案
按热度按时间ufj5ltwl1#
我不确定您想要实现什么,但下面是如何将所有4列转换为整数类型并调用
haversine
功能: