I want to get a list of the column headers from a pandas DataFrame.
(我想从pandas DataFrame获取列标题的列表。)
The DataFrame will come from user input so I won't know how many columns there will be or what they will be called. (DataFrame来自用户输入,所以我不知道会有多少列或它们将被称为什么。)
For example, if I'm given a DataFrame like this:
(例如,如果给我这样的DataFrame:)
>>> my_dataframe
y gdp cap
0 1 2 5
1 2 3 9
2 8 7 2
3 3 4 7
4 6 7 7
5 4 8 3
6 8 2 8
7 9 9 10
8 6 6 4
9 10 10 7
I would want to get a list like this:
(我想要一个这样的列表:)
>>> header_list
['y', 'gdp', 'cap']
ask by natsuki_2002 translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…