Let's say df
is a typical pandas.DataFrame
instance, I am trying to understand how come list(df)
would return a list of column names.
The goal here is for me to track it down in the source code to understand how list(<pd.DataFrame>)
returns a list of column names.
So far, the best resources I've found are the following:
- Get a list from Pandas DataFrame column headers
- Summary: There are multiple ways of getting a list of DataFrame column names, and each varies either in performance or idiomatic convention.
- SO Answer
- Summary: DataFrame follows a dict-like convention, thus coercing with
list()
would return a list of the keys of this dict-like structure.
- Summary: DataFrame follows a dict-like convention, thus coercing with
pandas.DataFrame
source code:- I can't find within the source code that point to how
list()
would create a list of column head names.
- I can't find within the source code that point to how