範囲
idという名前の単一のLongType列を持つ DataFrame を作成します。このデータフレームには、ステップ値がstepで、 startからend (含まない) までの範囲の要素が含まれます。
構文
Python
spark.tvf.range(start, end=None, step=1, numPartitions=None)
パラメーター
パラメーター | Type | 説明 |
|---|---|---|
| int | 開始値。 |
| int、オプション | 終了値(含まない)。 |
| int、オプション | 増分ステップ (デフォルト: 1)。 |
| int、オプション | DataFrame のパーティション数。 |
例
例1 : 開始、終了、ステップを指定して範囲を生成する
Python
spark.tvf.range(1, 7, 2).show()
Output
+---+
| id|
+---+
| 1|
| 3|
| 5|
+---+
例2 : 終了値のみの範囲を生成する
Python
spark.tvf.range(3).show()
Output
+---+
| id|
+---+
| 0|
| 1|
| 2|
+---+