2

How can I remove the index column from a dataframe loaded by Pandas? I have tried this: df_total = pd.read_csv(" ... ", index_col=False]), but Pandas continues to add automatically an index column on the left.

7
  • 2
    It is impossible, but you can set some column as index. You need always index in pandas. Commented Jan 24, 2017 at 17:26
  • 2
    What don't you like about it? Do you not like seeing it when it's printed out? Do you hate that pandas is keeping track of row positions? What is it you are trying to do such that a dataframe having an index gets in the way. Commented Jan 24, 2017 at 18:44
  • I'm trying to insert these data as input for a neural network, and seems that it recognizes one column more. Commented Jan 24, 2017 at 20:59
  • Post your code for the neural network, it's unlikely to be a pandas issue here, you only have a certain number of columns Commented Jan 24, 2017 at 21:07
  • 2
    Pandas always keeps track of an index column as said above. If you want to have access to the underlying data of the pandas dataframe consider df.values, where df is a dataframe instance. This returns the data without any index column as a numpy array. Commented Jan 26, 2017 at 21:41

1 Answer 1

2

Try:

df_total = pd.read_csv("xx.csv", index_col=0)

And it will use the first column as index.

Sign up to request clarification or add additional context in comments.

1 Comment

when you do that, that first column is no longer accessible by normal df['col name'] syntax :(

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.