pyspark.sql.functions.xpath_number#
- pyspark.sql.functions.xpath_number(xml, path)[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.
See also
pyspark.sql.functions.from_xml()pyspark.sql.functions.schema_of_xml()pyspark.sql.functions.to_xml()pyspark.sql.functions.xpath()pyspark.sql.functions.xpath_boolean()pyspark.sql.functions.xpath_double()pyspark.sql.functions.xpath_float()pyspark.sql.functions.xpath_int()pyspark.sql.functions.xpath_long()pyspark.sql.functions.xpath_short()pyspark.sql.functions.xpath_string()
Examples
>>> import pyspark.sql.functions as sf >>> spark.createDataFrame( ... [('<a><b>1</b><b>2</b></a>',)], ['x'] ... ).select(sf.xpath_number('x', sf.lit('sum(a/b)'))).show() +-------------------------+ |xpath_number(x, sum(a/b))| +-------------------------+ | 3.0| +-------------------------+