1

I am getting error while converting the numpy array to pandas dataframe. suppose I am adding the following arrays a and b using np.vstack

a=np.array((1,2,3,4))
b=np.array((11,22,33,44))
c=np.vstack((a,b))
pd.DataFrame(c)

The last command give the following error:

TypeError: 'numpy.ndarray' object is not callable

Where could be the mistake here?

6
  • its working fine for me, which pandas version are you using? Commented Apr 1, 2019 at 11:32
  • maybe dupe, maybe not - this, for me working nice. Commented Apr 1, 2019 at 11:33
  • @jezrael I dont know whats wrong here, the pandas version is 0.23.4 Commented Apr 1, 2019 at 11:34
  • 4
    clear your kernel. You might have overwritten pd.DataFrame accidentally. Try running again. Commented Apr 1, 2019 at 11:35
  • 1
    Or restart your IDE. Commented Apr 1, 2019 at 11:37

2 Answers 2

1
pd.DataFrame(data=c)

Thats an easy fix

>>> a=numpy.array((1,2,3,4))
>>> b=numpy.array((11,22,33,44))
>>> c=numpy.vstack((a,b))
>>> pd.DataFrame(data=c)
    0   1   2   3
0   1   2   3   4
1  11  22  33  44
Sign up to request clarification or add additional context in comments.

Comments

0

Do you have any other code than this you shared here? "TypeError: 'numpy.ndarray' object is not callable" means you have a variable of type 'numpy.ndarray' that tries to call something.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.