pyspark.sql.functions.xpath_double

pyspark.sql.functions.xpath_double(xml: ColumnOrName, path: ColumnOrName) → pyspark.sql.column.Column[source]

Returns a double value, the value zero if no match is found, or NaN if a match is found but the value is non-numeric.

New in version 3.5.0.

Examples

>>> df = spark.createDataFrame([('<a><b>1</b><b>2</b></a>',)], ['x'])
>>> df.select(xpath_double(df.x, lit('sum(a/b)')).alias('r')).collect()
[Row(r=3.0)]