• Register
1 vote
3.2k views

Problem:

I was trying some programs using numpy and pandas. I wrote a code which throws error, the code I wrote is :
 

data =pd.read_csv('arnob',sep=',')
data=data.values
P=np.ones((60,12))
Y=data[:,25] 

for i in range (3,20):
    X= np.column_stack((P,(dat[:,i])))
    Xt = np.transpose(X)
    p=np.matmul(Xt,X)

 

but after compiling this or running this a error message appears which is:

Traceback (most recent call last):
  File "test.py", line 5, in <module>
Traceback (most recent call last):
  File "test.py", line 1, in <module>
    data =pd.read_csv('arnob',sep=',')
NameError: name 'pd' is not defined

why am I getting this type of error message, can anyone help me to solve this.

8 6 2
4,980 points

Please log in or register to answer this question.

1 Answer

1 vote

Solution:

In your program your functions are not defined. So you should import the function first.

import numpy as np

import pandas as pd

And write your code as:
 

import numpy as np

import pandas as pd


data =pd.read_csv('arnob',sep=',')
data=data.values
P=np.ones((60,12))
Y=data[:,25] 

for i in range (3,20):
    X= np.column_stack((P,(dat[:,i])))
    Xt = np.transpose(X)
    p=np.matmul(Xt,X)

 

hope this will help you.If you still do not understand this feel free to ask me any thing you want to know.

Happy coding.

11 6 4
34,950 points

Related questions

0 votes
1 answer 69 views
69 views
Problem: could anybody help me ! NameError: name 'pd' is not defined.
asked Mar 6 Wafa Abu Yousef 6.1k points
0 votes
1 answer 29 views
29 views
Problem: I need to know what is the problem: traceback (most recent call last): NameError: name '&hellip;' is not defined
asked Mar 19 Wafa Abu Yousef 6.1k points
0 votes
1 answer 12 views
12 views
Problem: Any help: traceback (most recent call last): NameError: name '&hellip;' is not defined
asked Mar 19 Wafa Abu Yousef 6.1k points
0 votes
1 answer 27 views
27 views
Peroblem: How can I fix the issue? Thanks for your concern:Nameerror name is not defined python 3 .
asked Mar 15 Wafa Abu Yousef 6.1k points
0 votes
1 answer 34 views
34 views
Problem: How to I Solve this: python nameerror name is not defined function HELP! I need help understanding this: python nameerror name is not defined function Can someone please help solve this, I am new in python(). Someone have idea to solve this thanks!
asked Mar 5 Mashhoodch 13k points
0 votes
1 answer 19 views
19 views
Problem: How to I Solve this: nameerror: name 'include' is not defined HELP! I need help understanding this: nameerror: name 'include' is not defined Can someone please help solve this, I am new in python(). Someone have idea to solve this thanks!
asked Mar 3 Mashhoodch 13k points
0 votes
1 answer 426 views
426 views
Problem Hello Kodlogs, My code is giving me nameerror: name 'unicode' is not defined. Here is the code # utf-8 ? we need unicode if isinstance(unicode_or_str, unicode): text = unicode_or_str decoded = False else: text = unicode_or_str.decode(encoding) ... if isinstance(unicode_or_str, unicode): NameError: global name 'unicode' is not defined It started happening on Python 3. Please help
asked Nov 3, 2020 hashq 1.1k points
0 votes
1 answer 127 views
127 views
Am encountering this error in Windows Command line,done a wide search but could not get a perfect answer.Please find the error below and help in solving. python Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'python' is not defined >>> Thanks ... 31 '13 at 12:21 you did not include the >>> before the word 'python', right? &ndash; Elazar May 31 '13 at 12:23
asked Oct 25, 2020 psandprop 2.4k points
0 votes
1 answer 611 views
611 views
I've just installed python 3.5, ran Python 3.5 (32-bit) and typed pip and received the message: Traceback (most recent call last): File "<pyshell#2>", line 1, in <module> pip NameError: name 'pip' is not defined I don't see any scripts directories in my path, ... Scripts folder from above, same result. How do I install python so that it actually works (ie. I can run pip, install modules, etc.)?
asked Oct 25, 2020 psandprop 2.4k points
0 votes
2 answers 114 views
114 views
There has been an error when trying to run this script : input_variable = input ("Enter your name: ") print ("your name is" + input_variable) Let's say I type in "dude", the error I am getting is: line 1, in <module> input_variable = input ("Enter your name: ") File "<string>", line 1, in <module> NameError: name 'dude' is not defined I am running these scripts with Python 2.7.
asked Oct 24, 2020 psandprop 2.4k points