Series.to_frame
can be used to convert a Series
to DataFrame
.
# The provided name (columnName) will substitute the series name
df = series.to_frame('columnName')
For example,
s = pd.Series(["a", "b", "c"], name="vals")
df = s.to_frame('newCol')
print(df)
newCol
0 a
1 b
2 c