Removing index column in pandas

I have the following code which imports a CSV file. There are 3 columns and I want to set the first two of them to variables. When I set the second column to the variable "efficiency" the index column is also tacked on. How can I get rid of the index column?

    df = pd.DataFrame.from_csv('Efficiency_Data.csv', header=0, parse_dates=False)
    energy = df.index
    efficiency = df.Efficiency
    print efficiency

I tried using

    del df['index']

after I set

    energy = df.index

which I found in another post but that results in "KeyError: 'index' "

DataFrames and Series always have an index. Although it displays alongside the column(s), it is not a column, which is why del df['index'] did not work.

If you want to replace the index with simple sequential numbers, use df.reset_index(). I strongly suggest reading a little bit of the pandas documentation, like 10 minutes to Pandas to get a sense for why the index is there is how it is used.

From: stackoverflow.com/q/20107570

Back to homepage or read more recommendations: