To get a Series from a namedtuple you could use the _fields attribute:

In [11]: pd.Series(a, a._fields)
Out[11]:
ticker            GE
date      2010-01-01
price             30
dtype: object

Similarly you can create a DataFrame like this:

In [12]: df = pd.DataFrame(l, columns=l[0]._fields)

In [13]: df
Out[13]:
  ticker        date  price
0     GE  2010-01-01     30
1     GE  2010-01-02     31

You have to set_index after the fact, but you can do this inplace:

In [14]: df.set_index(['ticker', 'date'], inplace=True)

In [15]: df
Out[15]:
                   price
ticker date
GE     2010-01-01     30
       2010-01-02     31
Answer from Andy Hayden on Stack Overflow
🌐
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
🌐
TutorialsPoint
tutorialspoint.com › article › create-a-dataframe-with-customized-index-parameters-in-pandas
Create a DataFrame with customized index parameters in Pandas
August 30, 2021 - import pandas as pd df = pd.DataFrame( { "x": [5, 2, 1, 9], "y": [4, 1, 5, 10], "z": [4, 1, 5, 0] } ) print "Input DataFrame is: ", df df = pd.DataFrame( { "x": [5, 2, 1, 9], "y": [4, 1, 5, 10], "z": [4, 1, 5, 0] }, index=["John", "Jacob", "Ally", "Simon"] ) print "With Customized Index: ", df
🌐
PYnative
pynative.com › home › python › pandas › set index in pandas dataframe
Set index in pandas DataFrame
March 9, 2023 - We can use the parameter inplace to set the index in the existing DataFrame rather than create a new copy. df.set_index(inplace=True) ... Let’s see how we can set a specific column as an index in the DataFrame. In the below example, we have default index as a range of numbers replaced with ...
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.DataFrame.html
pandas.DataFrame — pandas 3.0.3 documentation - PyData |
Alignment is done on Series/DataFrame inputs. If data is a list of dicts, column order follows insertion-order. ... Index to use for resulting frame.
🌐
Saturn Cloud
saturncloud.io › blog › how-to-create-an-index-for-python-pandas-dataframe-a-comprehensive-guide
How to Create an Index for Python Pandas DataFrame: A Guide | Saturn Cloud Blog
July 10, 2023 - Indexes can be numeric, string, or even datetime. They can also be unique or non-unique. By default, Pandas assigns a numeric, auto-incrementing index to each DataFrame you create. ... Identification: Unique identifiers help in identifying rows with specific characteristics.
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.DataFrame.index.html
pandas.DataFrame.index — pandas 3.0.3 documentation
>>> df = pd.DataFrame({'Name': ['Alice', 'Bob', 'Aritra'], ... 'Age': [25, 30, 35], ... 'Location': ['Seattle', 'New York', 'Kona']}, ... index=([10, 20, 30])) >>> df.index Index([10, 20, 30], dtype='int64') In this example, we create a DataFrame with 3 rows and 3 columns, including Name, Age, and Location information.
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › different-ways-to-create-pandas-dataframe
Different ways to create Pandas Dataframe - GeeksforGeeks
January 2, 2025 - Explanation: To create a DataFrame by providing the index label explicitly, you can use the index parameter of the pd.DataFrame() constructor. The index parameter takes a list of index labels as input, and the DataFrame will use these labels ...
🌐
Data to Fish
datatofish.com › column-as-index-pandas-dataframe
How to Set Column as Index in a pandas DataFrame
# single column as index df.set_index('column', inplace=True) # Multiple column as index df.set_index(['column_a', 'column_b'], inplace=True) ... import pandas as pd data = {'fish': ['salmon', 'pufferfish', 'shark'], 'boat_id': [1, 2, 9], 'count': [100, 10, 1], } df = pd.DataFrame(data) print(df)
🌐
Pandas
pandas.pydata.org › pandas-docs › version › 0.13.1 › generated › pandas.DataFrame.html
pandas.DataFrame — pandas 0.13.1 documentation
>>> d = {'col1': ts1, 'col2': ts2} >>> df = DataFrame(data=d, index=index) >>> df2 = DataFrame(np.random.randn(10, 5)) >>> df3 = DataFrame(np.random.randn(10, 5), ... columns=['a', 'b', 'c', 'd', 'e']) Attributes · Methods · index · modules | next | previous | pandas 0.13.1 documentation » · API Reference » · © Copyright 2008-2014, the pandas development team. Created using Sphinx 1.1.3.
🌐
Python Examples
pythonexamples.org › pandas-set-column-as-index
Set Column as Index in Pandas DataFrame - Examples
Pandas – Set Column as Index: To set a column as index for a DataFrame, use DataFrame. set_index() function, with the column name passed as argument. You can also setup MultiIndex with multiple columns in the index. In this case, pass the array of column names required for index, to set_index() ...
🌐
Spark By {Examples}
sparkbyexamples.com › home › pandas › pandas set index name to dataframe
Pandas Set Index Name to DataFrame - Spark By {Examples}
December 4, 2024 - Use pandas.DataFrame.rename_axis() to set the index name/title, in order to get the index use DataFrame.index.name property and the same could be used to
🌐
TutorialsPoint
tutorialspoint.com › python-pandas-create-a-dataframe-from-original-index-but-enforce-a-new-index
Python Pandas - Create a DataFrame from original index but enforce a new index
October 13, 2021 - To create a DataFrame from original index but enforce a new index, use the index.to_frame(). Set the parameter index to False. At first, import the required libraries −
🌐
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 - In this method, we can set multiple columns of the Pandas DataFrame object as its index by creating a list of column names of the DataFrame then passing it to the set_index() function. That’s why in this case, the index is called multi-index.
🌐
Appdividend
appdividend.com › 2019 › 01 › 26 › pandas-set-index-example-python-set_index-tutorial
Pandas DataFrame set_index(): Setting an Index Column
September 23, 2025 - The set_index() method in Pandas sets one or more existing columns of a DataFrame as its index (row labels).
🌐
Programiz
programiz.com › python-programming › pandas › index
Pandas Index (With Examples)
Original DataFrame: Name Age City A John 25 New York B Alice 28 London C Bob 32 Paris Modified DataFrame: index Name Age City 0 A John 25 New York 1 B Alice 28 London 2 C Bob 32 Paris · We can access rows of a DataFrame using the .iloc property. For example, import pandas as pd # create a dataframe data = {'Name': ['John', 'Alice', 'Bob'], 'Age': [25, 28, 32], 'City': ['New York', 'London', 'Paris']} df = pd.DataFrame(data)
🌐
GeeksforGeeks
geeksforgeeks.org › pandas › pandas-dataframe-index
Pandas Dataframe Index - GeeksforGeeks
March 24, 2026 - import pandas as pd data = {'age': ... row = df.loc['Alice'] print(row) ... The set_index() method is used to change the index of a DataFrame by setting one or more columns as the new index....
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.DataFrame.from_dict.html
pandas.DataFrame.from_dict — pandas 3.0.3 documentation
>>> pd.DataFrame.from_dict(data, orient="index", columns=["A", "B", "C", "D"]) A B C D row_1 3 2 1 0 row_2 a b c d · Specify orient='tight' to create the DataFrame using a ‘tight’ format: