它具有使用 Excel 公式计算每个值的列
我尝试使用以下方式读取此文件:
input_MonthGroup_df = spark.read.format("com.crealytics.spark.excel") \
.option("header", "true") \
.option('inferSchema','true')\
.load(MonthGroup_file_path)
您可以使用下面的代码来读取制定的Excel文件:
import pandas as pd
import openpyxl
from pyspark.sql.types import StructType, StructField, DateType
df = pd.read_excel(<filePath>, engine="openpyxl")
schema = StructType([StructField("Month", DateType(), True), StructField("12 Month Lookback", DateType(), True)])
sdf = spark.createDataFrame(df, schema=schema)
sdf.show()
这将读取文件,如下所示: