79833269

Date: 2025-11-29 13:27:58
Score: 0.5
Natty:
Report link

When you run df.describe(), PySpark returns a DataFrame where every column is a String, so first we should cast the strings and then use pyspark.sql.functions.format_number to round the columns.

from pyspark.sql.functions import col, format_number

describe = df.describe()
columns = describe.columns[1:]

for column in columns:
    describe = describe.withColumn(
        column,
        format_number(col(column).cast('double'), 2)
    )

describe.show()
Reasons:
  • Has code block (-0.5):
  • Starts with a question (0.5): When you
  • Low reputation (0.5):
Posted by: AtilaSol