pyspark.sql.functions.shiftleft#

pyspark.sql.functions.shiftleft(col, numBits)[source]#

Shift the given value numBits left.

New in version 3.2.0.

Changed in version 3.4.0: Supports Spark Connect.

Parameters
colColumn or column name

input column of values to shift.

numBitsint

number of bits to shift.

Returns
Column

shifted value.

Examples

>>> import pyspark.sql.functions as sf
>>> spark.range(4).select("*", sf.shiftleft('id', 1)).show()
+---+----------------+
| id|shiftleft(id, 1)|
+---+----------------+
|  0|               0|
|  1|               2|
|  2|               4|
|  3|               6|
+---+----------------+