pd_df
이라는 pandas
데이터 프레임이 있습니다. 아래는 데이터 유형입니다.Spark는 pandas date time 데이터 유형을 bigint로 변환합니다.
pd_df.dtypes
id int64
TEST_TIME datetime64[ns]
status object
Pkg object
test_type object
test_name object
test_id int64
test_value float64
test_times int64
desc object
test_source object
GP float64
dtype: object
지금 나는 spark
데이터 프레임이 pd_df
을 변환 할.
나는 아래와 같이했습니다.
spark_df = sqlContext.createDataFrame(pd_df)
성공적으로 spark_df
을 만들 수있었습니다. 그러나 데이터 유형이 내 요구 사항과 일치하지 않습니다.
스파크 데이터 프레임의 필수 데이터 유형. 내가 가진 무엇
DataFrame[id: int, test_time: timestamp, status: string, pkg: string, test_type: string, test_name: string, test_id: int, test_value: double, test_times: int, desc: string, test_source: string, GP: double]
는
spark_df = sqlContext.createDataFrame(pd_df).withColumn('TEST_TIME1', unix_timestamp(col('TEST_TIME').cast("string"), "MM-dd-yyyy hh mm ss").cast("timestamp")).drop('TEST_TIME')
또한 "MM-DD-YYYY HH mm 교체, 어떻게 내가
데이터 샘플을 게시하십시오. – desertnaut