pyspark.pandas.Series.to_string

Series.to_string(buf: Optional[IO[str]] = None, na_rep: str = 'NaN', float_format: Optional[Callable[[float], str]] = None, header: bool = True, index: bool = True, length: bool = False, dtype: bool = False, name: bool = False, max_rows: Optional[int] = None) → Optional[str]

Render a string representation of the Series.

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, set max_rows parameter.

Parameters
bufStringIO-like, optional

buffer to write to

na_repstring, optional

string representation of NAN to use, default ‘NaN’

float_formatone-parameter function, optional

formatter function to apply to columns’ elements if they are floats default None

headerboolean, default True

Add the Series header (index name)

indexbool, optional

Add index (row) labels, default True

lengthboolean, default False

Add the Series length

dtypeboolean, default False

Add the Series dtype

nameboolean, default False

Add the Series name if not None

max_rowsint, optional

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

Returns
formattedstring (if not buffer passed)

Examples

>>> df = ps.DataFrame([(.2, .3), (.0, .6), (.6, .0), (.2, .1)], columns=['dogs', 'cats'])
>>> print(df['dogs'].to_string())
0    0.2
1    0.0
2    0.6
3    0.2
>>> print(df['dogs'].to_string(max_rows=2))
0    0.2
1    0.0