ValueError - Traceback, line 3
2 df = pl.DataFrame({'size': [34.2399, 1232.22, -479.1]})
----> 3 df.with_columns(pl.format('{:,.2f}', pl.col('size')))
File polars\functions\as_datatype.py:718, in format(f_string, *args)
717 msg = "number of placeholders should equal the number of arguments"
--> 718 raise ValueError(msg)
ValueError: number of placeholders should equal the number of arguments
def format(f_string: str, *args: Expr | str) -> Expr:
if f_string.count("{}") != len(args):
msg = "number of placeholders should equal the number of arguments"
raise ValueError(msg)
exprs = []
arguments = iter(args)
for i, s in enumerate(f_string.split("{}")):
if i > 0:
e = wrap_expr(parse_into_expression(next(arguments)))
exprs.append(e)
if len(s) > 0:
exprs.append(F.lit(s))
return concat_str(exprs, separator="")