pyspark.sql.functions.hash

pyspark.sql.functions.hash(*cols: ColumnOrName) → pyspark.sql.column.Column[source]

Calculates the hash code of given columns, and returns the result as an int column.

New in version 2.0.0.

Examples

>>> spark.createDataFrame([('ABC',)], ['a']).select(hash('a').alias('hash')).collect()
[Row(hash=-757602832)]