pd_df
というpandas
データフレームがあります。以下はデータ型です。sparkはpandas dateの時刻データ型を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
は今、私はこのpd_df
がspark
データフレームに変換します。
私は以下のように行っています。
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