简体   繁体   中英

Converting numpy array into pandas dataframe

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?

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM