faixa
Crie um DataFrame com uma única coluna LongType chamada id, contendo elementos em um intervalo de start a end (exclusivo) com o valor de passo step.
Sintaxe
Python
spark.tvf.range(start, end=None, step=1, numPartitions=None)
Parâmetros
Parâmetro | Tipo | Descrição |
|---|---|---|
| int | O valor inicial. |
| int, opcional | O valor final (exclusivo). |
| int, opcional | O passo incremental (default: 1). |
| int, opcional | O número de partições do DataFrame. |
Exemplos
Exemplo 1 : Gerar intervalo com começar, fim e o passo
Python
spark.tvf.range(1, 7, 2).show()
Output
+---+
| id|
+---+
| 1|
| 3|
| 5|
+---+
Exemplo 2 : Gerar intervalo com apenas o valor final
Python
spark.tvf.range(3).show()
Output
+---+
| id|
+---+
| 0|
| 1|
| 2|
+---+