Pandas dataframe in pyspark to hive

后端 未结 3 1495
时光说笑
时光说笑 2021-01-04 21:13

How to send a pandas dataframe to a hive table?

I know if I have a spark dataframe, I can register it to a temporary table using

df.registerTempTabl         


        
3条回答
  •  北荒
    北荒 (楼主)
    2021-01-04 21:53

    I converted my pandas df to a temp table by

    1) Converting the pandas dataframe to spark dataframe:

    spark_df=sqlContext.createDataFrame(Pandas_df)
    

    2) Make sure that the data is migrated properly

    spark_df.select("*").show()
    

    3) Convert the spark dataframe to a temp table for querying.

    spark_df.registerTempTable("table_name").
    

    Cheers..

提交回复
热议问题