הערה
הגישה לדף זה מחייבת הרשאה. באפשרותך לנסות להיכנס או לשנות מדריכי כתובות.
הגישה לדף זה מחייבת הרשאה. באפשרותך לנסות לשנות מדריכי כתובות.
Adds output options for the underlying data source.
Syntax
options(**options)
Parameters
| Parameter | Type | Description |
|---|---|---|
**options |
dict | String keys mapped to primitive-type values. For available options, see DataFrameWriter options. |
Returns
DataFrameWriter
Examples
Write a DataFrame into a CSV file with nullValue and header options set.
import tempfile
with tempfile.TemporaryDirectory(prefix="options") as d:
df = spark.createDataFrame([(100, None)], "age INT, name STRING")
df.write.options(nullValue="Alice", header=True).mode(
"overwrite").format("csv").save(d)
spark.read.option("header", True).format('csv').load(d).show()
# +---+------------+
# |age| name|
# +---+------------+
# |100|Alice|
# +---+------------+