ValueError: Usecols do not match columns, columns expected but not found是什么意思
时间: 2023-05-25 13:05:14 浏览: 1461
在使用Pandas读取CSV文件时,报出该错误通常表示:指定的列(usecols)与文件中实际存在的列不匹配。这可能是由于指定的列名称或索引错误、包含空格或制表符等不可见字符、列名称的大小写不匹配等原因引起的。建议检查列索引和列名以解决此问题。
相关问题
ValueError: Usecols do not match columns, columns expected but not found: ['分区', '中文', '语言'] (sheet: 0)
这个错误提示意味着你指定的 `usecols` 参数与文件中的列不匹配。具体来说,文件中缺少了你指定的一些列,例如 `分区`、`中文`、`语言` 列。
你可以尝试修改 `usecols` 参数,将该参数设置为文件中真实存在的列名。如果你想读取该文件中的所有列,可以不指定 `usecols` 参数,例如:
```python
df = pd.read_excel(r'分区.xlsx')
```
这样会读取该 Excel 文件中的所有列。如果你需要限制列,可以像这样指定:
```python
df = pd.read_excel(r'分区.xlsx', usecols=['区域', '国家'])
```
这样就只会读取 `区域` 和 `国家` 两列。如果文件中没有这些列,也会报错,需要检查一下文件中的列名是否正确。
ValueError: Expected 1D or 2D array, got 3D array instead
This error message is raised when a function or method expects a 1D or 2D array as input, but instead receives a 3D array.
A 1D array is a linear array with a single row or column, while a 2D array is a matrix with multiple rows and columns. A 3D array, on the other hand, has multiple layers or "slices" of 2D arrays.
The most common cause of this error is passing a 3D array to a function that expects a 2D array. To fix this error, you may need to reshape or flatten the input array to convert it to a 2D or 1D array, depending on the requirements of the function. Alternatively, you may need to modify the function to handle 3D arrays.
相关推荐
![py](https://img-home.csdnimg.cn/images/20210720083646.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)