הערה
הגישה לדף זה מחייבת הרשאה. באפשרותך לנסות להיכנס או לשנות מדריכי כתובות.
הגישה לדף זה מחייבת הרשאה. באפשרותך לנסות לשנות מדריכי כתובות.
Specifies the input data source format.
Syntax
format(source)
Parameters
| Parameter | Type | Description |
|---|---|---|
source |
str | The name of the data source, for example 'json' or 'parquet'. |
Returns
DataFrameReader
Examples
Write a DataFrame into a JSON file and read it back.
import tempfile
with tempfile.TemporaryDirectory(prefix="format") as d:
spark.createDataFrame(
[{"age": 100, "name": "Alice"}]
).write.mode("overwrite").format("json").save(d)
spark.read.format('json').load(d).show()
# +---+------------+
# |age| name|
# +---+------------+
# |100|Alice|
# +---+------------+