メインコンテンツまでスキップ

Excel(データフレームリーダー)

Excelファイルを読み込み、結果をDataFrameとして返します。

構文

excel(path, dataAddress=None, headerRows=None, listSheets=None,
dateFormat=None, timestampFormat=None)

パラメーター

パラメーター

Type

説明

path

文字列またはリスト

1つ以上の入力パス。

dataAddress

文字列、オプション

Excelファイル内のデータのアドレス。

headerRows

整数または文字列(省略可能)

ヘッダー行の数。

listSheets

bool または str、オプション

Trueの場合、データを読み込む代わりにシート名のリストを返します。

dateFormat

文字列、オプション

日付フォーマット文字列。

timestampFormat

文字列、オプション

タイムスタンプのフォーマット文字列。

戻り値

DataFrame

DataFrameをExcelファイルに書き込み、それを読み込む。

Python
import tempfile
with tempfile.TemporaryDirectory(prefix="excel") as d:
spark.createDataFrame(
[{"age": 100.1, "name": "Alice"}]
).write.mode("overwrite").option("headerRows", 1).excel(d)

spark.read.excel(d, headerRows=1).show()
# +-----+------------+
# | age| name|
# +-----+------------+
# |100.1|Alice|
# +-----+------------+
このページの見出し