-1

I want an array of values from dataframe.keys() method. But it returns an Index object, that have the header values array as a member. But I want only that array, no other details.

header_values=features_dataframe.keys() print(header_values) 

Output

Index(['header1', 'header2', 'header3', 'header4', 'header5','Target'], dtype='object')

But I want

['header1', 'header2', 'header3', 'header4', 'header5','Target']

4
  • I'm Sorry, but I'm not looking for Index, instead looking for headers! Commented Jul 12, 2020 at 6:05
  • Hi, please take a deep breath. I've re-assessed this and changed the duplicate to this one. This answer I personally endorse. Commented Jul 12, 2020 at 6:12
  • Okay :) but you can mark as duplicate without negative voting :p Commented Jul 12, 2020 at 6:13
  • 1
    Voting is anonymous here, please don't assume that someone downvoted you as you could always be assuming incorrectly. In this case I did not touch the downvote button on your question. Commented Jul 12, 2020 at 6:15

2 Answers 2

3

Try it:

header_values = list(features_dataframe.keys()) print(header_values) 
Sign up to request clarification or add additional context in comments.

Comments

0

try:

list(features_dataframe.index) 

1 Comment

This answer is incorrect, it returns the index instead of the columns.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.