def show_spark_df(df, n=20, truncate=True, vertical=False):
    """
    Show DataFrame as str, useful for logging.

    Notes
    -----
    Reimplemented from:
    https://spark.apache.org/docs/2.4.5/api/python/_modules/pyspark/sql/dataframe.html#DataFrame.show
    """
    if isinstance(truncate, bool) and truncate:
        return df._jdf.showString(n, 20, vertical)
    else:
        return df._jdf.showString(n, int(truncate), vertical)