The error is reproducible if the array is of dtype=object:

import numpy  as np

label0 = np.random.random((50, 3)).astype(object)
np.cov(label0, rowvar=False)

AttributeError: 'float' object has no attribute 'shape'

If possible you should convert it to a numeric type. For example:

np.cov(label0.astype(float), rowvar=False)  # works

Note: object arrays are rarely useful (they are slow and not all NumPy functions deal gracefully with these - like in this case), so it could make sense to check where it came from and also fix that.

Answer from MSeifert on Stack Overflow
🌐
Stack Overflow
stackoverflow.com › questions › 66213943 › how-to-use-cov-function-on-ndarray
python - How to use .cov() function on ndarray? - Stack Overflow
February 15, 2021 - Then I try to do .cov() ( Calculating the covariance matrix ) on that array, but it gives me and error 'numpy.ndarray' object has no attribute 'cov'
🌐
GitHub
github.com › rapidsai › cuml › issues › 2952
[QST] Error ('numpy.ndarray' object has no attribute 'to_pandas') while running MNMG Kmeans Demo Notebook · Issue #2952 · rapidsai/cuml
October 11, 2020 - [QST] Error ('numpy.ndarray' object has no attribute 'to_pandas') while running MNMG Kmeans Demo Notebook#2952
Author   rapidsai
🌐
GitHub
github.com › aertslab › pySCENIC › issues › 350
AttributeError: 'numpy.ndarray' object has no attribute 'quantile' when doing nGenesDetectedPerCell.quantile() · Issue #350 · aertslab/pySCENIC
December 22, 2021 - AttributeError Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_20596/2572477736.py in <module> 1 # STEP 4: Cellular enrichment (aka AUCell) from CLI 2 nGenesDetectedPerCell = np.sum(adata.X>0, axis=1) ----> 3 percentiles = nGenesDetectedPerCell.quantile([.01, .05, .10, .50, 1]) 4 print(percentiles) AttributeError: 'numpy.ndarray' object has no attribute 'quantile'
Author   aertslab
🌐
GitHub
github.com › AI4Finance-Foundation › FinRL › issues › 896
Error "'numpy.ndarray' object has no attribute 'values'" · Issue #896 · AI4Finance-Foundation/FinRL
February 16, 2023 - ~\AppData\Local\Temp\ipykernel_24604\3030550613.py in init(self, df, stock_dim, hmax, initial_amount, transaction_cost_pct, reward_scaling, state_space, action_space, tech_indicator_list, turbulence_threshold, lookback, day) 95 # load data from a pandas dataframe 96 self.data = self.df.loc[self.day,:] ---> 97 self.covs = self.data['cov_list'].values[0] 98 self.state = np.append(np.array(self.covs), [self.data[tech].values.tolist() for tech in self.tech_indicator_list ], axis=0) 99 self.terminal = False · AttributeError: 'numpy.ndarray' object has no attribute 'values' No one assigned ·
Author   AI4Finance-Foundation
🌐
Edureka Community
edureka.co › home › community › categories › python › numpy ndarray object has no attribute append
numpy ndarray object has no attribute append | Edureka Community
May 17, 2020 - This is part of my code, why it shows error. thanks in advance prets = [] pvols = ... : 'numpy.ndarray' object has no attribute 'append'
Find elsewhere
🌐
Researchdatapod
researchdatapod.com › home › how to solve python attributeerror: ‘numpy.ndarray’ object has no attribute ‘median’
How to Solve Python AttributeError: 'numpy.ndarray' object has no attribute 'median' - The Research Scientist Pod
May 16, 2022 - AttributeError occurs in a Python program when we try to access an attribute (method or property) that does not exist for a particular object. The median method belongs to the numpy class, not numpy.ndarray and it calculates a specified array’s ...
🌐
PyMC Discourse
discourse.pymc.io › questions › v5
AttributeError: 'numpy.ndarray' object has no attribute 'at' when sampling LKJ Cholesky Covariance Priors for Multivariate Normal Models example with numpyro or blackjax - v5 - PyMC Discourse
February 26, 2025 - I wanted to try out sampling with numpyro on an AMD GPU using a model based on this example: https://www.pymc.io/projects/examples/en/latest/howto/LKJ.html It works with PyMC and nutpie samplers, but not with jax samplers. The code I run looks like the following: import pymc as pm import numpy ...
🌐
Arab Psychology
scales.arabpsychology.com › psychological scales › how to fix “‘numpy.ndarray’ object has no attribute ‘index’
How To Fix "'numpy.ndarray' Object Has No Attribute 'index'
December 4, 2025 - While the initial instinct might be to convert the array into a different object type, such as a Pandas structure, to access a missing attribute, the most efficient and idiomatic solution involves utilizing existing NumPy functions. Applying the list-specific index() method directly to a numpy.ndarray fundamentally overlooks the design philosophy of NumPy, which prioritizes performance through vectorized operations over standard Python sequence methods.
🌐
NBShare
nbshare.io › notebook › 160784578 › How-To-Handle-nan-In-Numpy
How To Handle nan In Numpy - Nbshare Notebooks
AttributeError: 'numpy.ndarray' object has no attribute 'nanmean'. Correct way is to pass numpy array to nanmean function. ... Lets create another numpy vector of same dimensions as a. ... Lets do product of two vectors a and b. ... Lets see what is the covariance between array a and b.
🌐
freeCodeCamp
forum.freecodecamp.org › python
Medical Data Visualizer AttributeError: 'numpy.ndarray' object has no attribute - Python - The freeCodeCamp Forum
May 12, 2023 - I completed the project on google colab and everything seems to be working once I copy it over to replit. The charts seem to look good. However, I’m getting the following 2 errors on test: =============================…
🌐
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
Answer: The error is exactly what it says on the tin: NumPy’s ndarray object has no attribute [code ]append[/code] defined in its API. The error in question, for reference. We can start by asking, what is a numpy.ndarray? NumPy is an incredibly useful library for data manipulation in Python, wh...
🌐
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   oegedijk