pyspark.sql.functions.bit_length#
- pyspark.sql.functions.bit_length(col)[source]#
Calculates the bit length for the specified string column.
Added in version 3.3.0.
Changed in version 3.4.0: Supports Spark Connect.
- Parameters:
- col
Columnor column name Source column or strings. A column that evaluates to a string or binary.
- col
- Returns:
ColumnBit length of the col Returns a column that evaluates to an integer.
Examples
>>> from pyspark.sql import functions as sf >>> df = spark.createDataFrame([('cat',), ( '🐈',)], ['cat']) >>> df.select('*', sf.bit_length('cat')).show() +---+---------------+ |cat|bit_length(cat)| +---+---------------+ |cat| 24| | 🐈| 32| +---+---------------+