当前位置: 首页 > 工具软件 > determined > 使用案例 >

pyspark ValueError: Some of types cannot be determined after inferring

左丘弘致
2023-12-01

场景:当pandas的DF转换成spark的DF的时候报错 ValueError: Some of types cannot be determined after inferring

报错原因是     存在字段spark无法推断它的类型

解决方案,直接全部转换成str

b['request_market'] = b['request_market'].astype(str)
b['request_vin'] = b['request_vin'].astype(str)
b['request_brandCode'] = b['request_brandCode'].astype(str)
b['request_token'] = b['request_token'].astype(str)
b['response_msg'] = b['response_msg'].astype(str)
b['response_brandCode'] = b['response_brandCode'].astype(str)
b['response_data_source'] = b['response_data_source'].astype(str)
b['response_title'] = b['response_title'].astype(str)
b['response_img'] = b['response_img'].astype(str)
b['result'] = b['result'].astype(str)
b['api_path'] = b['api_path'].astype(str)
b['response_code'] = b['response_code'].astype(str)
b['create_time'] = b['create_time'].astype(str)
b['takeup_time'] = b['takeup_time'].astype(str)
b['response_code'] = b['response_code'].astype(str)
b['response_length'] = b['response_length'].astype(str)
b['response_feedback'] = b['response_feedback'].astype(str)
b['response_carsmodel'] = b['response_carsmodel'].astype(str)
b['response_query_time'] = b['response_query_time'].astype(str)
b['response_data'] = b['response_data'].astype(str)
b.dtypes

 

 类似资料:

相关阅读

相关文章

相关问答