【问题标题】:How to optimize the PySpark toPandas() with type hints如何使用类型提示优化 PySpark toPandas()
【发布时间】:2021-01-30 10:37:25
【问题描述】:

我之前没有在 PySpark 中看到过这个警告:

The conversion of DecimalType columns is inefficient and may take a long time. Column names: [PVPERUSER] If those columns are not necessary, you may consider dropping them or converting to primitive types before the conversion.

最好的处理方法是什么?这是传递给 toPandas() 的参数还是我需要以特定方式键入数据帧?

我的代码是与 pandas 的简单 pyspark 对话:

df = data.toPandas()

【问题讨论】:

    标签: pyspark


    【解决方案1】:

    试试这个:

    df = data.select(data.PVPERUSER.cast('float'), data.another_column).toPandas()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-05-12
      • 2021-11-10
      • 2021-02-13
      • 2019-02-02
      • 2021-05-07
      • 1970-01-01
      相关资源
      最近更新 更多