pyspark ValueError: Some of types cannot be determined after inferring
阿新 • • 發佈:2021-01-28
技術標籤:hivesparkpythonsparkhadooppandaspythonCDH
場景:當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