There's two issues here.

  1. By taking .values you actually access the underlying numpy array; you no longer have a pandas.Series. numpy arrays do not have an apply method.
  2. You are trying to use apply for a simple multiplication, which will be orders of magnitude slower than using a vectorized approach.

See below:

import pandas as pd
import numpy as np

df = pd.DataFrame({'a': np.arange(1000, dtype=np.float64)})
print(type(df['a']))
# Gives pandas.core.series.Series

print(type(df['a'].values))
# Gives numpy.ndarray

# The vectorized approach
df['a'] = df['a'] * 1.3
Answer from roganjosh on Stack Overflow
🌐
Researchdatapod
researchdatapod.com › home › how to solve python attributeerror: ‘numpy.ndarray’ object has no attribute ‘apply’
How to Solve Python AttributeError: 'numpy.ndarray' object has no attribute 'apply' - The Research Scientist Pod
September 14, 2024 - You can solve this error by not calling the values method and calling apply directly on the DataFrame or the Series. This tutorial will go through the error in detail and how to solve it with code examples.
Discussions

Error creating numpy v-stack, 'AttributeError: 'numpy.ndarray' object has no attribute 'np'
I think I'm using the wrong notation to append to the empty arrays: The best way to find out is to read the documentation https://numpy.org/doc/stable/reference/generated/numpy.append.html And yes you are. Numpy arrays don't have an append method, it's a function from the library. And there is no such thing as object.library.function(...) which is what you are doing here similarity.np.append(...) num_interactions.np.append(...) It should be similarity = np.append(similarity, values_to_append) num_interactions = np.append(num_interactions, values_to_append) And should avoid appending data to a numpy array. I'm almost sure there is much better alternative. But since you didn't explain what you are trying to do, I can't help you with that. More on reddit.com
🌐 r/learnpython
5
2
May 4, 2021
'numpy.ndarray' object has no attribute 'numpy'.
I tried to submit this to the repository linked in your publication, but, apparently, I can't! I received this error while running predictions: Traceback (most recent call last): File "/Us... More on github.com
🌐 github.com
1
November 16, 2023
scikit learn - AttributeError: 'numpy.ndarray' object has no attribute 'fit' - Data Science Stack Exchange
I am relatively new to ML and in the process of learning pipelines. I am creating a pipeline of custom transformers and get this error: AttributeError: 'numpy.ndarray' object has no attribute 'fit'. More on datascience.stackexchange.com
🌐 datascience.stackexchange.com
September 24, 2021
python - How to fix this error :AttributeError: 'numpy.ndarray' object has no attribute 'apply' - Stack Overflow
How to use the following code in the flask framework, because when I use the following code, always get this error "AttributeError: 'numpy.ndarray' object has no attribute 'apply'" mess... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Reddit
reddit.com › r/learnpython › error creating numpy v-stack, 'attributeerror: 'numpy.ndarray' object has no attribute 'np'
r/learnpython on Reddit: Error creating numpy v-stack, 'AttributeError: 'numpy.ndarray' object has no attribute 'np'
May 4, 2021 -

Hi,

I'm trying to create a numpy v-stack and creating 3 np.array's for it, by filling them with a loop:

I get the error: 'AttributeError: 'numpy.ndarray' object has no attribute 'np' . I think I'm using the wrong notation to append to the empty arrays:

neighbor_id = [id_ for id_ in range(1, n_obs) if id_ != user_id]

neighbor_id_arr = np.array(neighbor_id)

similarity = np.array([])

num_interactions = np.array([])

# get similarity and num_interactions

for id_ in neighbor_id:

similarity.np.append(np.dot(user_item.loc[user_id],user_item.loc[id_])) #The issue is here, I think

num_interactions.np.append(user_interactions.loc[id_])

c = numpy.vstack((neighbor_id_arr, similarity,num_interactions))

Thanks!
James

🌐
Quora
quora.com › Why-do-I-get-numpy-ndarray-object-has-no-attribute-append-error
Why do I get “numpy.ndarray object has no attribute append error”? - Quora
Summary The AttributeError is simply because ndarray has no append method. Choose the appropriate container or numpy function for your use case: list for frequent appends, preallocation for efficiency, or np.append/np.concatenate when copying ...
🌐
GitHub
github.com › waylandy › phosformer › issues › 1
'numpy.ndarray' object has no attribute 'numpy'. · Issue #1 · waylandy/phosformer
November 16, 2023 - Traceback (most recent call last): File "/Users/joshuasacher/phosformer/wip1_S234.py", line 17, in <module> predictions = Phosformer.predict_many( ^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/joshuasacher/phosformer/Phosformer/modules.py", line 204, in predict_many return np.array([i['pred'] for i in batch_job(kinases, peptides, **kwargs)]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/joshuasacher/phosformer/Phosformer/modules.py", line 204, in <listcomp> return np.array([i['pred'] for i in batch_job(kinases, peptides, **kwargs)]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/joshuasacher/phosformer/Phosformer/modules.py", line 96, in batch_job pred = softmax(result['logits'].cpu(), axis=1)[:,1].numpy() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'numpy.ndarray' object has no attribute 'numpy'.
Author   jrsacher
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-fix-numpy-ndarray-object-has-no-attribute-index
How to Fix: ‘numpy.ndarray’ object has no attribute ‘index’ - GeeksforGeeks
November 28, 2021 - ‘numpy.ndarray’ object has no attribute ‘index’ is an attribute error which indicates that there is no index method or attribute available to use in Numpy array.
Find elsewhere
🌐
GitHub
github.com › oegedijk › explainerdashboard › issues › 95
AttributeError: 'numpy.ndarray' object has no attribute 'columns' · Issue #95 · oegedijk/explainerdashboard
March 3, 2021 - AttributeError: 'numpy.ndarray' object has no attribute 'columns'#95 · Copy link · apavlo89 · opened · on Mar 3, 2021 · Issue body actions · This looks amazing but I can't run it on my dataset.
Author   apavlo89
🌐
Career Karma
careerkarma.com › blog › python › python attributeerror: ‘numpy.ndarray’ object has no attribute ‘append’ solution
Python AttributeError: 'numpy.ndarray' object has no attribute 'append' Solution
December 1, 2023 - Terms of Service and Privacy Policy govern the processing and handling of your data. The AttributeError: ‘numpy.ndarray’ object has no attribute ‘append’ error is caused by using the append() method to add an item to a NumPy array.
🌐
Statology
statology.org › home › how to fix: ‘numpy.ndarray’ object has no attribute ‘index’
How to Fix: 'numpy.ndarray' object has no attribute 'index'
September 17, 2021 - #attempt to print index position of minimum value x.index(min_val) AttributeError: 'numpy.ndarray' object has no attribute 'index' We receive an error because we can’t apply an index() function to a NumPy array.
🌐
Pythoneo
pythoneo.com › how-to-resolve-attributeerror-numpy-ndarray-object-has-no-attribute-function_name
How to Fix AttributeError: 'numpy.ndarray' Has No Attribute (Complete Guide) - Pythoneo: Python Programming, Seaborn & Plotly Tutorials
December 5, 2025 - ⚡ Quick Answer: This error means NumPy array doesn’t have the attribute you’re calling. Common causes: 1) Using pandas methods on NumPy arrays (.values, .append), 2) Misspelling attribute names, 3) Forgetting parentheses on methods. Check object type with type(obj) to confirm it’s actually ...
🌐
Groups
rasterio.groups.io › g › main › topic › attributeerror › 104814395
AttributeError: 'numpy.ndarray' object has no attribute 'transform' when rasterio.mask()
March 9, 2024 - You logged in using a passkey from another device. For faster access next time, add a passkey to this device · Note: Your email address is included with the abuse report
🌐
MNE Forum
mne.discourse.group › support & discussions
AttributeError: 'numpy.ndarray' object has no attribute 'get' - Support & Discussions - MNE Forum
May 17, 2021 - MNE-Python version: 0.23.0 operating system: Ubuntu 18.04.5 LTS -IDE: Pycharm-community import matplotlib import matplotlib.pyplot as plt import mne import numpy matplotlib.use('Qt5Agg') mne.set_log_level('warning') # Load raw data data_path = '/MNE/BrainVision/3.vhdr' raw = mne.io.read_raw_brainvision(data_path, preload=True, verbose=False) raw.info['line_freq'] = 50.
🌐
GitHub
github.com › hovren › crisp › issues › 12
AttributeError: 'numpy.ndarray' object has no attribute 'sqrt' · Issue #12 · hovren/crisp
March 12, 2019 - AttributeError: 'numpy.ndarray' object has no attribute 'sqrt' in function apply. All three video: rotation.MP4, walk.MP4, rccar.MP4 will fall into this error after some successfully computation for previous calling. I dumped the X data and found that X will be like below when reporting this error.
Author   roschachJoke
🌐
GeeksforGeeks
geeksforgeeks.org › how-to-fix-numpy-ndarray-object-has-no-attribute-append
How to Fix: ‘numpy.ndarray’ object has no attribute ‘append’ - GeeksforGeeks
November 28, 2021 - The output is pretty explanatory, the NumPy array has a type of numpy.ndarray which does not have any append() method. Now, we know that the append is not supported by NumPy arrays then how do we use it? It is actually a method of NumPy and not its array, let us understand it through the example given below, where we actually perform the append operation on a numpy list. ... values: numpy array or value: These values are appended to a copy of arr.
🌐
Stack Overflow
stackoverflow.com › questions › 40224987 › python-pandas-numpy-ndarray-object-has-no-attribute-apply › 40225054
Python Pandas: 'numpy.ndarray' object has no attribute 'apply' - Stack Overflow
October 24, 2016 - I am using apply on the ndarray ("unManager") for that, and am getting 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 am trying to convert the ndarray ("unManager") to a dataframe, through: dfs = pd.DataFrame(unManager,index=unManager[0]) I am getting the following error: --------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-55-3ee3d2605321> in <module>() ----> 1 dfs = pd.DataFrame(unManager,index=unManager[0]) .