Explanation:
AttributeError: ‘list’ object has no attribute ‘shape’
Property error: the ‘list’ object does not have the property ‘shape’
resolvent:
Use numpy or panda np.array Or dataframe has shape, which can be multi-dimensional, while list is one-dimensional and cannot be converted
If conversion is needed, list is converted to dataframe. Example:
a = [['a', 'b', 'c'], ['1', '2', '3'], ['张三', '张三', '张三']]
df = pd.DataFrame(a, columns=['one', 'two', 'three'])
print(df)
List to numpy example:
a = [['a', 'b', 'c'], ['1', '2', '3'], ['张三', '张三', '张三']]
data = np.array(a)
print(data)
Note: shape is a dimension. Only data frame and matrix have dimensions, while list is a slice single dimension
Read More:
- [Solved] Pytorch-transformers Error: AttributeError: ‘str‘ object has no attribute ‘shape‘
- How to Solve Python AttributeError: ‘dict’ object has no attribute ‘item’
- How to Solve Python AttributeError: ‘module’ object has no attribute ‘xxx’
- When sending an email, an error was reported: AttributeError:’list’ object has no attribute’encode’
- [Solved] AttributeError: ‘DataFrame‘ object has no attribute ‘map‘
- [Solved] AttributeError: ‘DataFrame‘ object has no attribute ‘tolist‘
- [Solved] AttributeError: ‘DataParallel‘ object has no attribute ‘save‘
- [Solved] AttributeError: ‘NoneType‘ object has no attribute ‘append‘
- [Solved] Networkx Error: Attributeerror: ‘graph’ object has no attribute ‘node’
- [Solved] AttributeError: ‘PngImageFile‘ object has no attribute ‘imshow‘
- AttributeError: DatetimeProperties object has no attribute
- [Solved] AttributeError: ‘NoneType‘ object has no attribute ‘astype‘
- [Solved] AttributeError: DataFrame object has no attribute’xxx’
- [Solved] vpython: AttributeError: ‘box‘ object has no attribute ‘idx‘
- [Solved] AttributeError: ‘str‘ object has no attribute ‘decode‘
- [Solved] AttributeError WriteOnlyWorksheet object has no attribute cell
- [Solved] Failed to initialize GLFW AttributeError: ‘NoneType’ object has no attribute ‘point_size’
- [Solved] AttributeError: ‘str‘ object has no attribute ‘decode‘
- [2021-10-05] Python Error: AttributeError: ‘NoneType‘ object has no attribute ‘append‘
- [Solved] Pycharm error: attributeerror: ‘Htmlparser’ object has no attribute ‘unescape’