Python Pandas: object 'numpy.ndarray' does not have attribute 'apply'

I have a dataframe from which I selected unique values, and this led to ndarray ("unManager") of the form (1187,) ... only one column.

Now I have written a function to group some rows of data, perform calculations, and add values ​​to ndarray.

I use ndarray ("unManager") for this, and I get the following error:

AttributeError                            Traceback (most recent call last)
<ipython-input-48-ff7e78ab33a7> in <module>()
----> 1 unManager.apply(runThis, axis=0)

AttributeError: 'numpy.ndarray' object has no attribute 'apply'

Now when I try to convert ndarray ("unManager") to dataframe, via:

dfs = pd.DataFrame(unManager,index=unManager[0])

I get the following error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-55-3ee3d2605321> in <module>()
----> 1 dfs = pd.DataFrame(unManager,index=unManager[0])
.
.
TypeError: Index(...) must be called with a collection of some kind, 'actama99,CLE' was passed

'actama99, CLE' here is the first value of ndarray ("unManager") of form (1187).

Can someone please tell me what I am doing wrong? TIA

+4
1
dfs = pd.DataFrame(unManager,index=unManager[0])

unManager[0] , collection.

dfs = pd.DataFrame(dict(unManagers=unManager))
0

Source: https://habr.com/ru/post/1658730/


All Articles