pyspark.pandas.Series.to_latex#
- Series.to_latex(buf=None, columns=None, header=True, index=True, na_rep='NaN', formatters=None, float_format=None, sparsify=None, index_names=True, bold_rows=False, column_format=None, longtable=None, escape=None, encoding=None, decimal='.', multicolumn=None, multicolumn_format=None, multirow=None)[source]#
Render an object to a LaTeX tabular environment table.
Render an object to a tabular environment table. You can splice this into a LaTeX document. Requires usepackage{booktabs}.
Note
This method should only be used if the resulting pandas object is expected to be small, as all the data is loaded into the driver’s memory. If the input is large, consider alternative formats.
- Parameters
- buffile descriptor or None
Buffer to write to. If None, the output is returned as a string.
- columnslist of label, optional
The subset of columns to write. Writes all columns by default.
- headerbool or list of str, default True
Write out the column names. If a list of strings is given, it is assumed to be aliases for the column names.
- indexbool, default True
Write row names (index).
- na_repstr, default ‘NaN’
Missing data representation.
- formatterslist of functions or dict of {str: function}, optional
Formatter functions to apply to columns’ elements by position or name. The result of each function must be a Unicode string. List must be of length equal to the number of columns.
- float_formatstr, optional
Format string for floating point numbers.
- sparsifybool, optional
Set to False for a DataFrame with a hierarchical index to print every multiindex key at each row. By default the value will be read from the config module.
- index_namesbool, default True
Prints the names of the indexes.
- bold_rowsbool, default False
Make the row labels bold in the output.
- column_formatstr, optional
The columns format as specified in LaTeX table format e.g. ‘rcl’ for 3 columns. By default, ‘l’ will be used for all columns except columns of numbers, which default to ‘r’.
- longtablebool, optional
By default the value will be read from the pandas config module. Use a longtable environment instead of tabular. Requires adding a usepackage{longtable} to your LaTeX preamble.
- escapebool, optional
By default the value will be read from the pandas config module. When set to False prevents from escaping latex special characters in column names.
- encodingstr, optional
A string representing the encoding to use in the output file, defaults to ‘ascii’ on Python 2 and ‘utf-8’ on Python 3.
- decimalstr, default ‘.’
Character recognized as decimal separator, e.g. ‘,’ in Europe.
- multicolumnbool, default True
Use multicolumn to enhance MultiIndex columns. The default will be read from the config module.
- multicolumn_formatstr, default ‘l’
The alignment for multicolumns, similar to column_format The default will be read from the config module.
- multirowbool, default False
Use multirow to enhance MultiIndex rows. Requires adding a usepackage{multirow} to your LaTeX preamble. Will print centered labels (instead of top-aligned) across the contained rows, separating groups via clines. The default will be read from the pandas config module.
- Returns
- str or None
If buf is None, returns the resulting LateX format as a string. Otherwise returns None.
See also
DataFrame.to_string
Render a DataFrame to a console-friendly tabular output.
DataFrame.to_html
Render a DataFrame as an HTML table.
Examples
>>> df = ps.DataFrame({'name': ['Raphael', 'Donatello'], ... 'mask': ['red', 'purple'], ... 'weapon': ['sai', 'bo staff']}, ... columns=['name', 'mask', 'weapon']) >>> print(df.to_latex(index=False)) \begin{tabular}{lll} \toprule name & mask & weapon \\ \midrule Raphael & red & sai \\ Donatello & purple & bo staff \\ \bottomrule \end{tabular}