120
Pandas Series.to_frame()
Series is defined as a type of list that can hold an integer, string, double values, etc. It returns an object in the form of a list that has an index starting from 0 to n where n represents the length of values in Series.
The main difference between Series and Data Frame is that Series can only contain a single list with a particular index, whereas the DataFrame is a combination of more than one series that can analyze the data.
The Pandas Series.to_frame() function is used to convert the series object to the DataFrame.
Syntax
Parameters
name: Refers to the object. Its Default value is None. If it has one value, the passed name will be substituted for the series name.
Returns
It returns DataFrame representation of Series.
Example1
Output
vals 0 a 1 b 2 c
Example2
Output
Emp ID 0 Parker 102 1 John 107 2 Smith 109 3 William 114
Next TopicSeries.unique()