1

I'm in a Python class right now and I was looking at switch from Atom and move to Spyder. My script imports and excel file, throws out 2 columns that I don't care about. I then rename the columns and try to output the results of one column. When I ran the code below in Atom, it worked fine. In Spyder, I get a traceback error.

import numpy as np
import pandas as pd

# Import the excel file I need. Also ignore certain rows I don't care about
energy = pd.read_excel('Energy Indicators.xls', skiprows=17, skipfooter=38)

# setup the new column names
nms = ['Country', 'Energy Supply', 'Energy Supply per Capita', '% Renewable']

# drop the columns I don't care about and rename the columns to what I want
energy = energy.drop(['Unnamed: 0', 'Unnamed: 1'], axis=1)
energy.columns = [nms]

# print out the column labeled 'Country'
print(energy['Country'])

In the Atom terminal, the script outputs a single column of the 'Country' Label (Which is what I want). In Spyder I get:

TypeError: only integer scalar arrays can be converted to a scalar index click here for error pic

moeses
  • 21
  • 1

0 Answers0