'numpy.ndarray' object has no attribute 'values'
时间: 2023-09-21 09:09:52 浏览: 209
将numpy.ndarray格式图像转化为_io.BufferedReader格式
This error occurs when you try to access the 'values' attribute of a NumPy array object. However, NumPy arrays do not have a 'values' attribute, and this attribute is specific to Pandas DataFrames or Series.
If you are trying to access the data of a NumPy array, you can simply use the array variable name. For example:
```
import numpy as np
my_array = np.array([1, 2, 3, 4, 5])
print(my_array)
```
This will output:
```
[1 2 3 4 5]
```
If you are working with a Pandas DataFrame or Series, you can access the data using the 'values' attribute. For example:
```
import pandas as pd
my_dataframe = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]})
print(my_dataframe.values)
```
This will output:
```
array([[1, 4],
[2, 5],
[3, 6]])
```
Make sure you are using the right object type and attribute name for your specific use case.
阅读全文