pandas 无法抑制PySpark警告

eni9jsuy  于 2023-02-02  发布在  Spark
关注(0)|答案(1)|浏览(180)

我有一些问题,试图压制pyspark警告,特别是Pandas对SparkAPI。我目前有:

import warnings
warnings.simplefilter(action='ignore', category=Warning)
warnings.filterwarnings("ignore")
import pandas as pd
from pyspark.sql import SparkSession
from pyspark.sql import functions as F
import pyspark.pandas as

%%capture
spark = SparkSession.builder\
    .master("local[32]")\
    .config("spark.driver.memory", "150g")
    .config("spark.driver.maxResultSize", "40g")\
    .config("spark.python.worker.memory", "1g")\
    .config("spark.num.executors","(3x-2)")\
    .config("spark.num.executor.cores","5")\
    .config("spark.driver.cores", "5")\
    .appName("Analysis")\
    .getOrCreate()
spark.sparkContext.setLogLevel("OFF")

然后进行实际数据分析:

spark.catalog.clearCache()
enc = ps.read_parquet("/example_path/")
enc.columns = [i.lower() for i in enc.columns]
print(enc.en_end_date.min())
print(enc.en_end_date.max())
enc['year'] = enc.en_end_date.apply(lambda x: x.strftime('%Y') if pd.notnull(x) else np.nan)
enc['month'] = enc.en_end_date.apply(lambda x: x.strftime('%m') if pd.notnull(x) else np.nan)
enc['day'] = enc.en_end_date.apply(lambda x: x.strftime('%d') if pd.notnull(x) else np.nan)
enc[(enc.year >= 2024) & (enc.month >= 1) & (enc.day >= 1)]

这就是真正的问题发生的地方。我被完全轰炸了:

/example/miniconda/lib/python3.8/site-packages/pyspark/python/lib/pyspark.zip/pyspark/pandas/internal.py:1573: FutureWarning: iteritems is deprecated and will be removed in a future version. Use .items instead.
/example/miniconda/lib/python3.8/site-packages/pyspark/python/lib/pyspark.zip/pyspark/pandas/internal.py:1573: FutureWarning: iteritems is deprecated and will be removed in a future version. Use .items instead.
/example/miniconda/lib/python3.8/site-packages/pyspark/python/lib/pyspark.zip/pyspark/pandas/internal.py:1573: FutureWarning: iteritems is deprecated and will be removed in a future version. Use .items instead.
/example/miniconda/lib/python3.8/site-packages/pyspark/python/lib/pyspark.zip/pyspark/pandas/internal.py:1573: FutureWarning: iteritems is deprecated and will be removed in a future version. Use .items instead.

几百次了。我只想把这个关掉。有什么建议吗。

5sxhfpxr

5sxhfpxr1#

对于任何有这个问题的人,回滚你的Pandas版本,直到警告停止,不幸的是没有其他方法来抑制这个问题。

相关问题