If len(X) is >1, axes will be a 2D array of AxesSubplot instances. So when you loop over axes, you actually get a slice along one dimension of the axes array.

To overcome this, you could use axes.flat:

for ax,_x in zip(axes.flat,X):

Also if you are trying to plot all these on one figure, you don't need to call plt.subplots twice, as that will create two figures.

It may be easier to index the axes array like this:

yy = func(*X)

fig, axes = plt.subplots(2, len(X))

for i,_x in enumerate(X):
    axes[0, i].plot(_x, y, 'b.')
    axes[0, i].plot(_x, yy, 'r.')

    axes[1, i].plot(_x, yy/y-1, 'r.')

plt.show()
Answer from tmdavison on Stack Overflow
🌐
Wgtn
ecs.wgtn.ac.nz › foswiki › pub › Support › ManualPagesAndDocumentation › numpybook.pdf pdf
Guide to NumPy Travis E. Oliphant, PhD Dec 7, 2006
Indexing is a powerful tool in Python and NumPy takes full advantage of this power. In fact, some of capabilities of Python’s indexing were first established by the needs · of Numeric users.2 Indexing is also sometimes called slicing in Python, and slicing · for an ndarray works very similarly as it does for other Python sequences. There · are three big differences: 1) slicing can be done over multiple dimensions, 2) exactly · one ellipsis object can be used to indicate several dimensions at once, 3) slicing
Discussions

[BUG] DiscreteDecisionTransformer Inference Problem, AttributeError: 'numpy.ndarray' object has no attribute 'length'
Traceback (most recent call last): ...site-packages\d3rlpy\algos\transformer\inputs.py", line 68, in from_numpy if context_size < inpt.length: AttributeError: 'numpy.ndarray' object has no attribute 'length'... More on github.com
🌐 github.com
4
May 15, 2024
AttributeError: 'numpy.ndarray' object has no attribute 'numpy'
@ptrblck, Hi! I’m trying to visualize the adversarial images generated by this script: https://pytorch.org/tutorials/beginner/fgsm_tutorial.html This tutorial is used for the mnist data. Now I want to use for other data which is trained using the inception_v1 architecture, below is the gist ... More on discuss.pytorch.org
🌐 discuss.pytorch.org
12
0
April 9, 2019
AttributeError: 'numpy.ndarray' object has no attribute 'read'
Video editing with Python. Contribute to Zulko/moviepy development by creating an account on GitHub. More on github.com
🌐 github.com
2
January 27, 2024
AttributeError: 'numpy.ndarray' object has no attribute 'pop'
Well, NumPy arrays do not have a .pop() method; those are on regular Python lists instead. You seem to use this for omitting grades less than 5. Maybe NumPy's boolean indexing could work here, e.g. marks = np.array([ [8.0, 9.0, 10.0], [4.0, 9.0, 8.0], [8.0, 3.0, 8.0], [10.0, 9.0, 5.0], [9.0, 9.0, 4.0] ]) omitted_5 = np.array([ row[~(row < 5)] # Keep those that are NOT less than 5 for row in marks ]) # array([array([ 8., 9., 10. ]), # array([ 9., 8. ]), # array([ 8., 8. ]), # array([ 10., 9., 5. ]), # array([ 9., 9. ])], # dtype=object) However, this results in an irregularly shaped data, which interferes with the GPA computation with credits. QUESTION: How would marks with omitted values behave with the GPA computation? For example, the last set of marks [9.0, 9.0, 4.0] which will essentially be filtered into [9.0, 9.0] Will it only get multiplied to [2, 2]? (Filtered credits values) Or should it instead be filtered into [9.0, 9.0, 0.0] and fully multiplied with [2, 2, 1]? (Unfiltered credits) More on reddit.com
🌐 r/learnpython
4
1
November 28, 2022
🌐
Esri Community
community.esri.com › t5 › arcgis-pro-questions › attributeerror-module-numpy-has-no-attribute-str › td-p › 1247961
Solved: AttributeError: module 'numpy' has no attribute 's... - Esri Community
January 13, 2023 - c:\Users\user\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone-1\lib\site-packages\arcgis\auth\tools\_lazy.py:48: FutureWarning: In the future `np.str` will be defined as the corresponding NumPy scalar. (This may have returned Python scalars in past versions. Output exceeds the size limit. Open the full output data in a text editor --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-13-404f875978ff> in <module> 3 m.center = [55.472155,13.032001] 4 ----> 5 pd.DataFrame.spatial.from_featureclass(arcpy.env.wo
🌐
GitHub
github.com › takuseno › d3rlpy › issues › 392
[BUG] DiscreteDecisionTransformer Inference Problem, AttributeError: 'numpy.ndarray' object has no attribute 'length' · Issue #392 · takuseno/d3rlpy
May 15, 2024 - Traceback (most recent call last): File "D:\simulation\models\d3rlpy_offline_rl\offline_rl_dt_d3rl.py", line 84, in actions = algo.predict(state_list) File "D:\venv\lib\site-packages\d3rlpy\algos\transformer\base.py", line 219, in predict torch_inpt = TorchTransformerInput.from_numpy( File "D:\venv\lib\site-packages\d3rlpy\algos\transformer\inputs.py", line 68, in from_numpy if context_size < inpt.length: AttributeError: 'numpy.ndarray' object has no attribute 'length'
Published   May 15, 2024
Author   waltersharpWEI
🌐
Itsourcecode
itsourcecode.com › home › attributeerror: numpy.ndarray object has no attribute plot
Attributeerror: numpy.ndarray object has no attribute plot
March 21, 2023 - Resolving the error attributeerror: numpy.ndarray object has no attribute plot is an easy task. All you have to do is convert the NumPy array to a pandas DataFrame. In doing this, we’ll be able to use the plot() method.
🌐
GitHub
github.com › Zulko › moviepy › issues › 2103
AttributeError: 'numpy.ndarray' object has no attribute 'read'
January 27, 2024 - AttributeError Traceback (most recent call last) [/usr/local/lib/python3.10/dist-packages/PIL/Image.py](https://localhost:8080/#) in open(fp, mode, formats) 2978 try: -> 2979 fp.seek(0) 2980 except (AttributeError, io.UnsupportedOperation): AttributeError: 'numpy.ndarray' object has no attribute 'seek' During handling of the above exception, another exception occurred: AttributeError Traceback (most recent call last) 11 frames <decorator-gen-178> in set_make_frame(self, mf) <decorator-gen-128> in get_frame(self, t) [/usr/local/lib/python3.10/dist-packages/PIL/Image.py](https://localhost:8080/#) in open(fp, mode, formats) 2979 fp.seek(0) 2980 except (AttributeError, io.UnsupportedOperation): -> 2981 fp = io.BytesIO(fp.read()) 2982 exclusive_fp = True 2983 AttributeError: 'numpy.ndarray' object has no attribute 'read'
Author   sugizo
🌐
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 - This error occurs when you attempt to use the index() function on a NumPy array, which does not have an index attribute available to use.
Find elsewhere
🌐
DOKUMEN.PUB
dokumen.pub › guide-to-numpy-1nbsped.html
Guide to NumPy [1&nbsp;ed.] - DOKUMEN.PUB
In fact, some of capabilities of Python’s indexing were first established by the needs of Numeric users.2 Indexing is also sometimes called slicing in Python, and slicing for an ndarray works very similarly as it does for other Python sequences. There are three big differences: 1) slicing can be done over multiple dimensions, 2) exactly one ellipsis object can be used to indicate several dimensions at once, 3) slicing cannot be used to expand the size of an array (unlike lists). A few examples should make slicing more clear. Suppose A is a 10 × 20 array, then A[3] is the same as A[3, :] and represents the 4th length-20 “row” of the array.
🌐
Reddit
reddit.com › r/learnpython › attributeerror: 'numpy.ndarray' object has no attribute 'pop'
r/learnpython on Reddit: AttributeError: 'numpy.ndarray' object has no attribute 'pop'
November 28, 2022 -

Write a function to calculate accumulated GPA (omit grade <5).

def gpa_of_pass(marks, credits):
    gpa_list=[]
    for i in range(len(marks)):
        for j in range(len(marks[i])):
            if marks[i][j] < 5:
                marks=marks[i].pop(j)
    for i in marks:
        for j in i:
            gpa_list.append(np.dot(i,credits)/sum(credits))
    return gpa_list

marks = np.array([
    [8.0, 9.0, 10.0],
    [4.0, 9.0, 8.0],
    [8.0, 3.0, 8.0],
    [10.0, 9.0, 5.0],
    [9.0, 9.0, 4.0]
])

credits = np.array([2, 2, 1])
gpa_of_pass(marks, credits)

I ran a for loop to remove the grade <5 before calculating the GPA but I got the error in the title. Would you please have any suggestions? Thank you so much!

🌐
NumPy
numpy.org › doc › 2.1 › reference › generated › numpy.ndarray.size.html
numpy.ndarray.size — NumPy v2.1 Manual
Number of elements in the array · Equal to np.prod(a.shape), i.e., the product of the array’s dimensions
🌐
NumPy
numpy.org › devdocs › release › 1.20.0-notes.html
NumPy 1.20.0 Release Notes — NumPy v2.5.dev0 Manual
If dtype="S" is provided the results will be largely identical to before, but NumPy scalars (not a Python float like 1.0), will still enforce a uniform string length: np.array([np.float64(3.)], dtype="S") # gives "S32" np.array([3.0], dtype="S") # gives "S3" Previously the first version gave the same result as the second. Array coercion has been restructured. In general, this should not affect users. In extremely rare corner cases where array-likes are nested: ... This can subtly change output for some badly defined array-likes. One example for this are array-like objects which are not also sequences of matching shape.
🌐
freeCodeCamp
forum.freecodecamp.org › python
Attribute error during testing - Python - The freeCodeCamp Forum
October 5, 2021 - Tell us what’s happening: The test module fails giving the error 'numpy.ndarray' object has no attribute 'get_xlabel'. A very similar error comes up in the second test. Additionally for some reasons the values in my correlation matrix are wrong. This is the console output: python main.py ...
🌐
Facebook
facebook.com › groups › python.malaysia › posts › 10156136553996380
AttributeError: 'numpy.ndarray' object has no attribute ' ...
Popular groups · Find communities for you · Over 1 billion people across the globe are using Facebook Groups to explore their favorite topics · Log in · Categories · Science & tech · Travel · Animals · Sports & fitness · Entertainment
🌐
GitHub
github.com › santoshphilip › eppy › issues › 96
AttributeError: 'numpy.ndarray' object has no attribute 'extend' · Issue #96 · santoshphilip/eppy
April 11, 2016 - AttributeError: 'numpy.ndarray' object has no attribute 'extend'#96 · Copy link · nancynanxiaodan · opened · on Apr 11, 2016 · Issue body actions · Hi all, I got an error saying that 'numpy.ndarray' object(which is the schedule in the following code) has no attribute 'extend'. for i in range(7): for schedulename in range(len(ScheduleCompact)): if ScheduleCompact[schedulename].Name == OccupancySchedule[i][0]: Schedule = ScheduleCompact.pop(schedulename) p = len(OccupancySchedule[i]) - 1 + 5 if len(Schedule['obj']) < p: number_extra_array_space = p-len(Schedule['obj']) extra_array_space=['
Author   nancynanxiaodan
🌐
DeepLearning.AI
community.deeplearning.ai › course q&a › tensorflow developer professional › natural language processing in tensorflow
Why am I getting this numpy error with this code? - Natural Language Processing in TensorFlow - DeepLearning.AI
March 19, 2025 - The code: ### START CODE HERE ### # mentor edit: code removed ### END CODE HERE ### The Error: AttributeError Traceback (most recent call last) Cell In[29], line 2 1 # Test your code! ----> 2 unittests.test_n_gram_seqs(n_gram_seqs) File /tf/unittests.py:228, in test_n_gram_seqs(learner_func) 224 cases.append(t) 226 return cases → 228 cases = g() 229 print_feedback(cases) File /tf/unittests.py:215, in test_n_gram_seqs..g() 212 t...
🌐
Hugging Face
discuss.huggingface.co › 🤗transformers
Error occuring during usig .to_tf_dataset() - 🤗Transformers - Hugging Face Forums
December 9, 2023 - What should I do in this case? The continuation of the error:“AttributeError: module ‘numpy’ has no attribute ‘object’. np.object was a deprecated alias for the builtin object. To avoid this error in existing code, use object by itself. Doing this will not modify any behavior and is safe.
🌐
CuPy
docs.cupy.dev › en › stable › reference › generated › cupy.ndarray.html
cupy.ndarray — CuPy 14.0.1 documentation
Object containing memory-layout information. It only contains c_contiguous, f_contiguous, and owndata attributes. All of these are read-only. Accessing by indexes is also supported. ... Size of each element in bytes. ... Matrix-transpose view of the array. If ndim < 2, raise a ValueError. ... Total size of all elements in bytes. It does not count skips between elements. ... Number of dimensions. ... Lengths of axes.