Lưu ý
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử đăng nhập hoặc thay đổi thư mục.
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử thay đổi thư mục.
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|
# +---+------------+