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 › 72159124 › attributeerror-float-object-has-no-attribute-reshape
python - "AttributeError: 'float' object has no attribute 'reshape'." - Stack Overflow
# similarity matrix sim_mat = np.zeros([len(cleaned_texts), len(cleaned_texts)]) for i in range(len(sentences)): for j in range(len(sentences)): if i != j: sim_mat[i][j] = cosine_similarity(sentence_vectors[i].reshape(1, dim), sentence_vectors[j].reshape(1, dim))[0, 0] sim_mat = np.round(sim_mat, 3) # print(sim_mat)
🌐
YouTube
youtube.com › watch
Solving the AttributeError: 'float' object has no attribute 'reshape' in Python with NumPy - YouTube
Discover the reason behind the `AttributeError` in Python when using NumPy and learn how to fix it effectively to ensure your code runs smoothly.---This vide...
Published   May 25, 2025
Views   3
🌐
YouTube
youtube.com › the python oracle
AttributeError: 'float' object has no attribute 'shape' when using linregress - YouTube
Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn--Music by Eric Matyashttps://www.soundimage.orgTrack title: The Buil...
Published   January 22, 2023
Views   369
🌐
GitHub
github.com › activeloopai › Hub › issues › 316
[BUG] 'float' object has no attribute 'shape' in Data pipelines · Issue #316 · activeloopai/deeplake
December 13, 2020 - 🐛🐛 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 res_ds = out_ds.store(tag) File "/Hub/hub/compute...
Author   davidbuniat
🌐
Python Forum
python-forum.io › thread-13879.html
'list' object has no attribute 'reshape'
November 4, 2018 - Hi All, I've just joined this forum, also new to Python, with background in other languages. I've been trying a small piece of code below using jupyter ipython in notebooks.azure.com, the error is coming from the last call for np.reshape function w...
🌐
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
🌐
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): ...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
🌐
GitHub
github.com › apple › coremltools › issues › 424
AttributeError: 'float' object has no attribute 'flatten' · Issue #424 · apple/coremltools
August 20, 2019 - Will not be assigned to a release. (type) ... /anaconda3/envs/inpaint-coreml/lib/python3.6/site-packages/coremltools/models/neural_network/builder.py in add_load_constant_nd(self, name, output_name, constant_value, shape) 5311 5312 data = spec_layer_params.data -> 5313 data.floatValue.extend(map(float, constant_value.flatten())) 5314 spec_layer_params.shape.extend(shape) 5315 · AttributeError: 'float' object has no attribute 'flatten'
Author   edis219
🌐
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 - a float object does not have an attribute `shape` because it is not an array. However, there are a few workarounds for this issue, such as converting the float object to an array, using the `shape` attribute of the `parent` object of the float ...
🌐
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.
🌐
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.
🌐
Unmet Hours
unmethours.com › question › 68535 › error-float-object-has-no-attribute-apply
Error: 'float' object has no attribute 'apply' - Unmet Hours
This variable is set a few lines above with the .get_actuator_handle method, which returns -1 if the object can't be found or one of the parameters (state, component_type, control_type, actuator_key) are set incorrectly. Have you initialized state = api.state_manager.new_state() before this? Otherwise "LIV1XWIN_SCH" may not be the correct schedule name.
🌐
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 › Joshuaalbert › jaxns › issues › 40
AttributeError: 'float' object has no attribute 'shape' · Issue #40 · Joshuaalbert/jaxns
October 19, 2021 - You must be signed in to change notification settings · Fork 17 · Star 193 · New issueCopy link · New issueCopy link · Closed · Closed · AttributeError: 'float' object has no attribute 'shape'#40 · Copy link · Labels · bugSomething isn't workingSomething isn't working ·
Author   jecampagne
🌐
Researchdatapod
researchdatapod.com › home › how to solve python attributeerror: ‘float’ object has no attribute ’round’
How to Solve Python AttributeError: 'float' object has no attribute 'round' - The Research Scientist Pod
September 25, 2024 - AttributeError occurs in a Python ... “‘float’ object has no attribute ‘round’” tells us that the float data type does not have the attribute round()....
🌐
GitHub
github.com › Theano › Theano › issues › 1935
Elemwise perform: AttributeError: 'int' object has no attribute 'shape' · Issue #1935 · Theano/Theano
June 21, 2014 - I've stumbled upon a situation where, during graph optimization, a pure Python 'int' is passed to Elemwise.perform, but the current implementation expects a NumPy array because it assumes the 'shape' attribute (theano/tensor/elemwise.py:778). I'm not sure about the correct fix. Should numpy.asarray be applied to all inputs first? That might lead to incorrect floatX types though if an input is a Python float type and floatX=float32.
Author   sisp
🌐
GitHub
github.com › spectralpython › spectral › issues › 50
'classifiers.pyc' line 202 error = "object has no attribute 'reshape' " · Issue #50 · spectralpython/spectral
June 21, 2016 - 0.0%--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-27-77f389619efe> in <module>() ----> 1 clmap = gmlc.classify_image(img_fld) python2.7/site-packages/spectral/algorithms/classifiers.pyc in classify_image(self, image) 200 status.display_percentage('Processing...') 201 shape = image.shape --> 202 image = image.reshape(-1, shape[-1]) 203 scores = np.empty((image.shape[0], len(self.classes)), np.float64) 204 delta = np.empty_like(image, dtype=np.float64) AttributeError: 'TransformedImage' object has no attribute 'reshape' Reactions are currently unavailable ·
Author   fdovila