pyspark.sql.SQLContext.range#
- SQLContext.range(start, end=None, step=1, numPartitions=None)[source]#
Create a
DataFramewith singlepyspark.sql.types.LongTypecolumn namedid, containing elements in a range fromstarttoend(exclusive) with step valuestep.Added in version 1.4.0.
- Parameters:
- startint
the start value
- endint, optional
the end value (exclusive)
- stepint, optional
the incremental step (default: 1)
- numPartitionsint, optional
the number of partitions of the DataFrame
- Returns:
Examples
>>> sqlContext.range(1, 7, 2).collect() [Row(id=1), Row(id=3), Row(id=5)]
If only one argument is specified, it will be used as the end value.
>>> sqlContext.range(3).collect() [Row(id=0), Row(id=1), Row(id=2)]