'numpy.ndarray' object has no attribute 'columns'
时间: 2023-09-21 17:06:55 浏览: 156
将numpy.ndarray格式图像转化为_io.BufferedReader格式
This error occurs when you try to access the 'columns' attribute of a NumPy array object. NumPy arrays do not have a 'columns' attribute since they are not structured data like pandas dataframes.
If you are trying to access a specific column of a NumPy array, you can do so using indexing. For example, if you have a 2D NumPy array called 'arr' and you want to access the first column, you can do:
```
arr[:, 0]
```
This will return a 1D array containing all the values in the first column of 'arr'.
If you need to work with structured data, you may want to consider using pandas dataframes instead of NumPy arrays. Pandas dataframes are designed for working with tabular data and have many useful attributes and methods for manipulating and analyzing data.
阅读全文