cudf.Series.to_string#

Series.to_string(
buf=None,
*,
na_rep: str = 'NaN',
float_format=None,
header: bool = True,
index: bool = True,
length: bool = False,
dtype: bool = False,
name: bool = False,
max_rows: int | None = None,
min_rows: int | None = None,
) str | None[source]#

Render a Series to a console-friendly string output.

cuDF uses pandas internals for string formatting, so this mirrors pandas.Series.to_string() and accepts the same arguments. Unlike repr, the output is not truncated by the display.max_rows option unless max_rows is passed explicitly, and the dtype/name/length footer is omitted unless requested.

cuDF supports null/None as a value in any column type, which is transparently supported during this output process.

Parameters:
bufwritable buffer, optional

File path or buffer to write to. If None (default), the output is returned as a string.

na_repstr, default “NaN”

String representation of NaN/null values.

float_formatcallable, optional

One-parameter formatter function applied to floating point values.

headerbool, default True

Whether to print the Series header (the index name).

indexbool, default True

Whether to print index (row) labels.

lengthbool, default False

Whether to append the Series length to the output.

dtypebool, default False

Whether to append the Series dtype to the output.

namebool, default False

Whether to append the Series name to the output.

max_rowsint, optional

Maximum number of rows to show before truncating. If None, all rows are shown.

min_rowsint, optional

Number of rows to show in a truncated output (when the number of rows exceeds max_rows).

Returns:
str or None

The string representation of the Series when buf is None; otherwise the result is written to buf and None is returned.

Examples

>>> import cudf
>>> series = cudf.Series([1, 2, 3, 4])
>>> series.to_string()
'0    1\n1    2\n2    3\n3    4'