You can also try this :

df = DataFrame(series).transpose()

Using the transpose() function you can interchange the indices and the columns. The output looks like this :

    a   b   c
0   1   2   3
Answer from PJay on Stack Overflow
Top answer
1 of 2
3

I don't have your dataframe, but here's an example with small data to show that pandas contructs the dataframe as expected (using pandas 0.15.1 and python 3.4). As expected, NaNs are introduced when the indices don't match.

The last row of your data is ('intercept', ''), while all the other rows are numbers. So ('intercept', '') goes to the index of each series, and this is probably causing the values in the index to be "promoted" to strings.

>> s1 = pd.Series([1,2,3], index=pd.MultiIndex.from_tuples([(1,1),(1,2),(1,3)], names=['a','b']))
>>> s1
a  b
1  1    1
   2    2
   3    3
dtype: int64
>>> s2 = pd.Series([100,200,300], index=pd.MultiIndex.from_tuples([(1,2),(1,3),(1,4)], names=['a','b']))
>>> 
>>> s2
a  b
1  2    100
   3    200
   4    300
dtype: int64
>>> df = pd.DataFrame({'s1':s1, 's2':s2})
>>> df
     s1   s2
a b         
1 1   1  NaN
  2   2  100
  3   3  200
  4 NaN  300
>>> df.index.values
array([(1, 1), (1, 2), (1, 3), (1, 4)], dtype=object)
2 of 2
2

The reason that it is converting the indexes to strings is because the last index

intercept                             [-11.4551819018]

in your series data is a string. The documentation for the Pandas data frames state that when constructing a data frame from a series the data frame keeps the same indexing from the series which causes the conversion to all strings because of the last line in the data.

Your solution to create two data frames and then joining them works because the indexing is consistent since you're using the same data structure (e.g. data frame) rather than converting from one data structure (series) to another (data frame). It seems to be a Pandas specific thing. I would stick with your solution.

๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ convert-given-pandas-series-into-a-dataframe-with-its-index-as-another-column-on-the-dataframe
Convert given Pandas series into a dataframe with its index as another column on the dataframe - GeeksforGeeks
August 17, 2020 - # importing pandas package import ... with its index as another column on the dataframe by using Series.to_frame() and Dataframe.reset_index() methods together....
๐ŸŒ
Pandas
pandas.pydata.org โ€บ docs โ€บ reference โ€บ api โ€บ pandas.Series.html
pandas.Series โ€” pandas 3.0.3 documentation
Values must be hashable and have the same length as data. Non-unique index values are allowed. Will default to RangeIndex (0, 1, 2, โ€ฆ, n) if not provided. If data is dict-like and index is None, then the keys in the data are used as the index.
๐ŸŒ
Data Science Dojo
discuss.datasciencedojo.com โ€บ python
How to transform a Pandas Series index into a DataFrame column? - Python - Data Science Dojo Discussions
February 16, 2023 - I have faced this problem several times and found a way to solve it using the reset_index() method in Pandas. This method adds a new sequential index to the series and converts the previous index into a column.
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ creating-a-dataframe-from-pandas-series
Creating a Dataframe from Pandas series
April 20, 2023 - Now, we can create a DataFrame from the series object using the `pd.DataFrame()` method. For example, ... This will create a DataFrame with two columns: one for the index and one for the values in the series. To assign a name to the column containing the values in the series, we can use the ...
Find elsewhere
๐ŸŒ
Pandas
pandas.pydata.org โ€บ docs โ€บ reference โ€บ api โ€บ pandas.Index.to_frame.html
pandas.Index.to_frame โ€” pandas 3.0.3 documentation
Convert Series to DataFrame. ... >>> idx = pd.Index(["Ant", "Bear", "Cow"], name="animal") >>> idx.to_frame() animal animal Ant Ant Bear Bear Cow Cow
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ creating-a-dataframe-from-pandas-series
Creating a dataframe from Pandas series - GeeksforGeeks
September 29, 2023 - By default, if the new index contains labels not present in the orig ... Mapping external values to a dataframe means using different sets of values to add to that dataframe by keeping the keys of the external dictionary as same as the one column of that dataframe. To add external values to dataframe, we use a dictionary that has keys and values which we want to add to t ... Pandas use various methods to reshape the dataframe and series.
๐ŸŒ
w3resource
w3resource.com โ€บ python-exercises โ€บ pandas โ€บ index โ€บ pandas-indexing-exercise-12.php
Pandas: Construct a series using the MultiIndex levels - w3resource
September 6, 2025 - import pandas as pd import numpy as np sales_arrays = [['sale1', 'sale1', 'sale2', 'sale2', 'sale3', 'sale3', 'sale4', 'sale4'], ['city1', 'city2', 'city1', 'city2', 'city1', 'city2', 'city1', 'city2']] sales_tuples = list(zip(*sales_arrays)) print("Create a MultiIndex:") sales_index = pd.MultiIndex.from_tuples(sales_tuples, names=['sale', 'city']) print(sales_tuples) print("\nConstruct a series using the said MultiIndex levels: ") s = pd.Series(np.random.randn(8), index = sales_index) print(s)
๐ŸŒ
Pandas
pandas.pydata.org โ€บ docs โ€บ reference โ€บ api โ€บ pandas.DataFrame.set_index.html
pandas.DataFrame.set_index โ€” pandas 3.0.3 documentation
>>> df = pd.DataFrame( ... { ... "month": [1, 4, 7, 10], ... "year": [2012, 2014, 2013, 2014], ... "sale": [55, 40, 84, 31], ... } ... ) >>> df month year sale 0 1 2012 55 1 4 2014 40 2 7 2013 84 3 10 2014 31 ... >>> df.set_index([pd.Index([1, 2, 3, 4]), "year"]) month sale year 1 2012 1 55 2 2014 4 40 3 2013 7 84 4 2014 10 31 ... >>> s = pd.Series([1, 2, 3, 4]) >>> df.set_index([s, s**2]) month year sale 1 1 1 2012 55 2 4 4 2014 40 3 9 7 2013 84 4 16 10 2014 31
๐ŸŒ
Pandas
pandas.pydata.org โ€บ docs โ€บ reference โ€บ api โ€บ pandas.Series.reset_index.html
pandas.Series.reset_index โ€” pandas 3.0.3 documentation
Series.reset_index(level=None, *, drop=False, name=<no_default>, inplace=False, allow_duplicates=False)[source]# Generate a new DataFrame or Series with the index reset.
๐ŸŒ
Data Science Dojo
discuss.datasciencedojo.com โ€บ python
How to combine multiple Series to create a DataFrame in Python using Pandas? - Python - Data Science Dojo Discussions
February 17, 2023 - A series is similar to a column in a dataframe, while a dataframe is an object that can hold multiple columns or multiple series objects. In other words, series objects are one-dimensional (index and values) while dataframes objects are multi-dimensional. Since a dataframe is essentially made up of several series, there must be ways of combining, merging, or joining multiple series objects to create a single dataframe.
๐ŸŒ
AskPython
askpython.com โ€บ home โ€บ pandas dataframe indexing: set the index of a pandas dataframe
Pandas DataFrame Indexing: Set the Index of a Pandas Dataframe - AskPython
February 16, 2023 - First, we will create a Python list and pass it to the pd.Series() function which returns a Pandas series that can be used as the DataFrame index object. Then we pass the returned Pandas series to the set_index() function to set it as the new ...