apache-spark - PySpark 脚本缓慢,体积非常小
问题描述
在 8 核/32G Windows 计算机上运行以下 Python 脚本大约需要 40 分钟。为什么这么慢?
for he in range(1, 25):
he_str = str(he)
### df_all is a dataframe that contains only 3200 records ###
### df_all does contain 146 columns. Maybe this is why? ###
df_all = df_all.withColumn('PROFIT_INC_HE' + he_str, functions.lit(0))
df_all = df_all.withColumn('PROFIT_DEC_HE' + he_str, functions.lit(0))
### TIER_PRICE_FACTORS is list of 4 elements ###
for tiers in TIER_PRICE_FACTORS:
tiers_str = str(tiers).replace('.', '')
df_all = df_all.withColumn('PROFIT_INC_HE' + he_str, functions.col('PROFIT_INC_HE' + he_str) \
+ functions.col('BID_PROFIT_INC_HE' + he_str + '_' + tiers_str))
df_all = df_all.withColumn('PROFIT_DEC_HE' + he_str, functions.col('PROFIT_DEC_HE' + he_str) \
+ functions.col('BID_PROFIT_Dec_HE' + he_str + '_' + tiers_str))
解决方案
推荐阅读
- maven - Netbeans 运行不会在 glassfish 上部署 ear maven
- cassandra - 白天频繁更新的数据的 Cassandra 压缩策略
- sql-server - 服务代理 - 多个队列与一个队列
- mysql - Kubernetes:使用 MySQL 容器创建 StatefulSet 时出错
- php - 如何使用codeigniter将多个复选框值插入数据库
- python - 将 BeautifulSoup 函数应用于 Pandas DataFrame
- javascript - 在对象中使用方法不会给我值
- asp.net - 如何使用 MS Access 数据库在 ISS 中设置现有的 asp 站点?
- ruby-on-rails - 检查字符串是否属于枚举作为值
- c++ - 在 Visual Studio 2015 中链接 .lib