Jump to content
Sign in to follow this  
zak100

Python pandas: Name Error

Recommended Posts

Hi,

I am trying to execute the following code:


 

df2 = pd.DataFrame(np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]), columns=['a', 'b', 'c'])
df2 = pd.DataFrame(data=d, dtype=np.int8)

print(df2)

I am getting the following error message:

Quote

df2 = pd.DataFrame(np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]), columns=['a', 'b', 'c'])
NameError: name 'np' is not defined

Somebody please guide me.

 

Zulfi.

 

Share this post


Link to post
Share on other sites
24 minutes ago, zak100 said:

NameError: name 'np' is not defined


What happens of you import numpy?

Quote

import numpy as np

 

Share this post


Link to post
Share on other sites

Hi,

Your solution worked.

Thanks a lot for your help.

God blesses you.

 

Zulfi.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.