pandas.Series.to_string#
- Series.to_string(
- buf=None,
- *,
- na_rep=<no_default>,
- float_format=None,
- header=True,
- index=True,
- length=False,
- dtype=False,
- name=False,
- max_rows=None,
- min_rows=None,
Render a string representation of the Series.
Produces a human-readable text format of the Series, including optional display of the index, data types, name, and length. The output can be written to a buffer or returned as a string.
- Parameters:
- bufStringIO-like, optional
Buffer to write to.
- na_repstr, optional
String representation of missing values. By default
NaN,NaT,NoneandNAare each shown as themselves.- float_formatone-parameter function, optional
Formatter function to apply to columns’ elements if they are floats, default None.
- headerbool, default True
Add the Series header (index name).
- indexbool, default True
Add index (row) labels.
- lengthbool, default False
Add the Series length.
- dtypebool, default False
Add the Series dtype.
- namebool, default False
Add the Series name if not None.
- max_rowsint, optional
Maximum number of rows to show before truncating. If None, show all.
- min_rowsint, optional
The number of rows to display in a truncated repr (when number of rows is above max_rows).
- Returns:
- str or None
String representation of Series if
buf=None, otherwise None.
See also
Series.to_dictConvert Series to dict object.
Series.to_frameConvert Series to DataFrame object.
Series.to_markdownPrint Series in Markdown-friendly format.
Series.to_timestampCast to DatetimeIndex of Timestamps.
Examples
>>> ser = pd.Series([1, 2, 3]).to_string() >>> ser '0 1\n1 2\n2 3'