Nota
Capaian ke halaman ini memerlukan kebenaran. Anda boleh cuba mendaftar masuk atau menukar direktori.
Capaian ke halaman ini memerlukan kebenaran. Anda boleh cuba menukar direktori.
Separates col1, ..., colk into n rows. Uses column names col0, col1, etc. by default unless specified otherwise.
Syntax
spark.tvf.stack(n, *fields)
Parameters
| Parameter | Type | Description |
|---|---|---|
n |
pyspark.sql.Column |
The number of rows to separate. |
fields |
pyspark.sql.Column |
Input elements to be separated. |
Returns
pyspark.sql.DataFrame: A DataFrame with the stacked rows.
Examples
import pyspark.sql.functions as sf
spark.tvf.stack(sf.lit(2), sf.lit(1), sf.lit(2), sf.lit(3)).show()
+----+----+
|col0|col1|
+----+----+
| 1| 2|
| 3|NULL|
+----+----+