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
🌐
GitHub
github.com › scipy › scipy › issues › 17441
BUG: AttributeError: 'float' object has no attribute 'shape' · Issue #17441 · scipy/scipy
November 18, 2022 - Describe your issue. I tried to plot QQ plot by using stats.probplot, but raised AttributeError. Reproducing Code Example stats.probplot( df['col'], dist="norm", plot=pylab ) pylab.show() Error message AttributeError: 'float' object has ...
Author   bhaskoro-muthohar
Discussions

[BUG] 'float' object has no attribute 'shape' in Data pipelines
🐛🐛 Bug Report ⚗️ Current Behavior Receive float object has no attribute shape inside data pipelines. Traceback (most recent call last): File "examples/upload_mpi.py", line 52, in More on github.com
🌐 github.com
3
December 13, 2020
AttributeError: 'float' object has no attribute 'shape'
Hello, I had in mind to repeat the GammaPrior example but for other distribution but I face some crashes. I am using JaxNS version 0.0.7 true_mu= 1. true_sigma = 2. def log_likelihood(_myprior, **k... More on github.com
🌐 github.com
3
October 19, 2021
python - AttributeError: 'float' object has no attribute 'shape' when using seaborn - Stack Overflow
I Imagine this is an issue with ... the same AttributeError says it's because it's not the same type of class, and as shown above my dataFrame has the same type of class as the one in seaborn's documentation. ... I got the same problem and was trying to find a solution but did not see the answer I was looking for. So I guess provide an answer here may help people like me. The problem here is that the type of df.total_bill is object instead of float... More on stackoverflow.com
🌐 stackoverflow.com
Some functions raise an unhelpful error when applied to object array
Traceback (most recent call last): ...lib/python3.7/site-packages/numpy/lib/function_base.py", line 428, in average if scl.shape != avg.shape: AttributeError: 'float' object has no attribute 'shape'... More on github.com
🌐 github.com
4
February 17, 2020
🌐
DeepLearning.AI
community.deeplearning.ai › course q&a › natural language processing › nlp with classification and vector spaces
Unit test throwing error on predictions, 'float' object has no attribute 'shape' - NLP with Classification and Vector Spaces - DeepLearning.AI
January 25, 2022 - I have written my predict_tweet function, and the outputs seem to be correct: However, when I run the unit test, I get an error on the unit test itself. Obviously something is wrong on my end, something is not an array when it should be. I have a feeling it is the sigmoid function, which I had to vectorize before, but when I vectorize it here, it gives me a different error…
🌐
GitHub
github.com › activeloopai › Hub › issues › 316
[BUG] 'float' object has no attribute 'shape' in Data pipelines · Issue #316 · activeloopai/deeplake
December 13, 2020 - Expected behavior/code Data pipelines should be able to process floats without creating a NumPy array. Python version(s): [Clang 11.0.3 (clang-1103.0.32.62)] on darwin ... The problem underlies in setting dynamic shapes.
Author   davidbuniat
🌐
GitHub
github.com › Joshuaalbert › jaxns › issues › 40
AttributeError: 'float' object has no attribute 'shape' · Issue #40 · Joshuaalbert/jaxns
October 19, 2021 - AttributeError: 'float' object has no attribute 'shape'#40 · Copy link · Labels · bugSomething isn't workingSomething isn't working · Milestone · Release 1.0 · jecampagne · opened · on Oct 19, 2021 · Issue body actions · Hello, I had in mind to repeat the GammaPrior example but for other distribution but I face some crashes.
Author   jecampagne
🌐
GitHub
github.com › numpy › numpy › issues › 15587
Some functions raise an unhelpful error when applied to object array · Issue #15587 · numpy/numpy
February 17, 2020 - Traceback (most recent call last): ...lib/python3.7/site-packages/numpy/lib/function_base.py", line 428, in average if scl.shape != avg.shape: AttributeError: 'float' object has no attribute 'shape'...
Author   Wrzlprmft
Find elsewhere
🌐
Bobby Hadz
bobbyhadz.com › blog › python-attributeerror-float-object-has-no-attribute
AttributeError: 'float' object has no attribute 'X' (Python) | bobbyhadz
The Python "AttributeError: 'float' object has no attribute" occurs when we try to access an attribute that doesn't exist on a floating-point number, e.g.
🌐
GitHub
github.com › numpy › numpy › issues › 23527
BUG: <Error in the Numpy 'cov()' function: ' prefix> · Issue #23527 · numpy/numpy
April 4, 2023 - Describe the issue: The numpy covariance matrix has a bug as it is saying float has no shape, but why is it calling shape on a float? Reproduce the code example: import numpy as np covariance_matrix = np.cov(data_matrix, rowvar=False) Er...
Author   arnav10goel
🌐
GitHub
github.com › sktime › pytorch-forecasting › issues › 1220
fitting a single series causing torch to throw 'float' object has no attribute 'shape' · Issue #1220 · sktime/pytorch-forecasting
January 7, 2023 - Getting AttributeError: 'float' object has no attribute 'shape' as I try to fit a simple time series.
Author   soycaporal
🌐
HatchJS
hatchjs.com › home › float object has no attribute ‘shape’: what it means and how to fix it
Float Object Has No Attribute 'Shape': What It Means and How to Fix It
January 5, 2024 - For example, the following code accesses the element at the first row and second column of the array: ... The error “float object has no attribute ‘shape'” occurs when you try to access the shape attribute of a float object.
🌐
Stack Overflow
stackoverflow.com › questions › 74486687 › scipy-stats-probplot-raised-attributeerror-float-object-has-no-attribute-sh
python - scipy.stats.probplot raised `AttributeError: 'float' object has no attribute 'shape'` - Stack Overflow
AttributeError: 'float' object has no attribute 'shape' when using seaborn · 2 · ValueError: The shape of all parameters · 0 · modifying scipy stats.probplot plotting function with matplotlib · 0 · Python/Pandas: TypeError: float() argument must be a string or a number, not 'function' Load 7 more related questions Show fewer related questions ·
🌐
Stack Overflow
stackoverflow.com › questions › 72415037 › float-object-has-no-attribute-shape
python - 'float' object has no attribute 'shape' - Stack Overflow
2605 How do I parse a string to a float or int? 3324 Convert bytes to a string · 2182 How to know if an object has an attribute in Python · 2027 Determine the type of an object? 1117 Is there a simple way to delete a list element by value? 1197 pg_config executable not found ·
🌐
Bokeh Discourse
discourse.bokeh.org › community support
AttributeError: 'float' object has no attribute 'on_change' - Community Support - Bokeh Discourse
July 19, 2022 - I have 30 lines in one plot and I want to add sliders to change the trends of those lines. I used plot.multi_line to graph out the initial plot. I want to try CustomJS but I need to call my own function deriv1 with solve_ivp to have new y.data but I am not sure how to do so.
🌐
OpenCV
forum.opencv.org › t › attributeerror-nonetype-object-has-no-attribute-shape › 4910
AttributeError: 'NoneType' object has no attribute 'shape' - imgcodecs - OpenCV
August 24, 2021 - What is this error?? Traceback (most recent call last): File "code.py", line 1717, in shape height, width = input.shape AttributeError: 'NoneType' object has no attribute 'shape' This is the code: input = cv2.imread('IMAGES/UAV.tif') #, cv2.IMREAD_UNCHANGED) height, width = input.shape print("HEIGHT:", height) print("WIDTH:", width)