snowflake.snowpark.functions.to_decimal¶
- snowflake.snowpark.functions.to_decimal(e: Union[Column, str], precision: int, scale: int) Column [source] (https://github.com/snowflakedb/snowpark-python/blob/v1.26.0/snowpark-python/src/snowflake/snowpark/functions.py#L1936-L1951)¶
Converts an input expression to a decimal.
- Example::
>>> df = session.create_dataframe(['12', '11.3', '-90.12345'], schema=['a']) >>> df.select(to_decimal(col('a'), 38, 0).as_('ans')).collect() [Row(ANS=12), Row(ANS=11), Row(ANS=-90)]
>>> df.select(to_decimal(col('a'), 38, 2).as_('ans')).collect() [Row(ANS=Decimal('12.00')), Row(ANS=Decimal('11.30')), Row(ANS=Decimal('-90.12'))]