pandas.Series.to_frame — pandas 2.2.3 documentation (original) (raw)

Series.to_frame(name=<no_default>)[source]#

Convert Series to DataFrame.

Parameters:

nameobject, optional

The passed name should substitute for the series name (if it has one).

Returns:

DataFrame

DataFrame representation of Series.

Examples

s = pd.Series(["a", "b", "c"], ... name="vals") s.to_frame() vals 0 a 1 b 2 c

On this page

Show Source