3 Replies - 178 Views - Last Post: 21 February 2020 - 02:42 PM Rate Topic: -----

#1 SacPy   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 26
  • Joined: 18-June 19

NameError: name 'Index' is not defined

Posted 21 February 2020 - 05:02 AM

Hi,

I am using below code to import CSV file. I am getting error at last line of the code.
In the 'Code analysis' I can see undefined name 'Index'.

Can anyone please help me understand how to resolve this.

import pandas as MyPandas
import matplotlib.pyplot as MyMatplot
dataFrame = MyPandas.read_csv('Python Chart Data.txt', skiprows=8)
print(dataFrame.columns)
Index(['YEARMODA', 'TEMP', 'MAX', 'MIN'], dtype='object')



Is This A Good Question/Topic? 0
  • +

Replies To: NameError: name 'Index' is not defined

#2 ndc85430   User is offline

  • I think you'll find it's "Dr"
  • member icon

Reputation: 994
  • View blog
  • Posts: 3,901
  • Joined: 13-June 14

Re: NameError: name 'Index' is not defined

Posted 21 February 2020 - 05:29 AM

You need to import Index, surely (or qualify it by the module name if you're already importing the right thing, like you're doing on line 3 for example)? Also, what do you expect line 5 to do? That value is just being thrown away.
Was This Post Helpful? 1
  • +
  • -

#3 SacPy   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 26
  • Joined: 18-June 19

Re: NameError: name 'Index' is not defined

Posted 21 February 2020 - 05:36 AM

Hi ndc85430 sir, thanks for the help. Could you please help me understand how do I import Index.
These are the next steps for me.

x = dataFrame['YEARMODA']
y = dataFrame['TEMP']
plt.plot(x, y)
plt.show()


Was This Post Helpful? 0
  • +
  • -

#4 ndc85430   User is offline

  • I think you'll find it's "Dr"
  • member icon

Reputation: 994
  • View blog
  • Posts: 3,901
  • Joined: 13-June 14

Re: NameError: name 'Index' is not defined

Posted 21 February 2020 - 02:42 PM

Which module or package is Index in?
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1