range (SparkSession)
Crée un DataFrame avec une seule colonne LongType nommée id, contenant des éléments dans une plage allant de start à end (exclusivement) avec une valeur d’étape step.
Syntaxe
range(start, end=None, step=1, numPartitions=None)
parameter
parameter | Type | Description |
|---|---|---|
| int | La valeur start. |
| int, facultatif | La valeur finale (exclusive). Si omis, |
| int, facultatif | L'étape incrémentielle (default : |
| int, facultatif | Le nombre de partitions du |
Renvoie
DataFrame
Exemples
Python
spark.range(1, 7, 2).show()
# +---+
# | id|
# +---+
# | 1|
# | 3|
# | 5|
# +---+
# If only one argument is specified, it is used as the end value.
spark.range(3).show()
# +---+
# | id|
# +---+
# | 0|
# | 1|
# | 2|
# +---+