簡體   English   中英

從火花 dataframe 到 pandas dataframe

[英]from spark dataframe to pandas dataframe

我有一個火花 dataframe 我是通過這種方式創建的:

tx_df = (spark
         .read
         .parquet("/data/file"))



tx_ecommerce = tx_df.filter(tx_df["POS_Cardholder_Presence"]=="ECommerce").show()

我嘗試將 tx_commerce 轉換為 pandas dataframe。 我試過這樣:

tx_ecommerce.toPandas()

但我得到了這個錯誤:

-------------------------------------------------- ------------------------- ----> 1 tx_ecommerce.toPandas() 中的 AttributeError Traceback(最近一次調用最后一次)

AttributeError: 'NoneType' object 沒有屬性 'toPandas'

請幫忙解決這個問題?

謝謝

當您將.show() 放在最后時,它不再是 pyspark 數據幀。

刪除它,它應該可以工作。

tx_ecommerce =tx_df.filter(tx_df["POS_Cardholder_Presence"]=="ECommerce")

tx_ecommerce.toPandas()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM