"None of [Index(['salary'], dtype='object')] are in the [columns]"
时间: 2023-10-09 14:07:45 浏览: 51
这个错误通常发生在你试图使用一个不存在的列名来访问 DataFrame 的时候。请确保你的 DataFrame 中包含一个名为 'salary' 的列,并且列名的大小写与你的代码中一致。你可以使用 df.columns 方法来检查 DataFrame 中所有的列名。如果这个问题仍然存在,请提供更多的代码和数据细节,以便我能够更好地帮助你解决这个问题。
相关问题
C语言代码,输入一个职工的月薪 salary,输出应交的个人所得税tax(保留2 位小数)。 tax = rate * (salary-3500) - deduction 当 salary <= 3500 时,rate = 0,deduction=0; 当 3500 < salary <= 5000时,rate = 3%,deduction=0; 当 5000 < salary <= 8000时,rate = 10%,deduction=105; 当 8000 < salary <=12500 时,rate =20%,deduction=555; 当 12500 < salary <= 38500 时,rate =25%,deduction=1005; 当 38500 < salary <=58500 时,rate =30%,deduction=2755; 当 58500 < salary <= 83500 时,rate =35%,deduction=5505; 当 83500 < salary 时,rate =45%,deduction=13505;
```c
#include <stdio.h>
int main() {
float salary, tax, rate, deduction;
scanf("%f", &salary);
if (salary <= 3500) {
rate = 0;
deduction = 0;
} else if (salary <= 5000) {
rate = 0.03;
deduction = 0;
} else if (salary <= 8000) {
rate = 0.1;
deduction = 105;
} else if (salary <= 12500) {
rate = 0.2;
deduction = 555;
} else if (salary <= 38500) {
rate = 0.25;
deduction = 1005;
} else if (salary <= 58500) {
rate = 0.3;
deduction = 2755;
} else if (salary <= 83500) {
rate = 0.35;
deduction = 5505;
} else {
rate = 0.45;
deduction = 13505;
}
tax = rate * (salary - 3500) - deduction;
printf("%.2f", tax);
return 0;
}
```
SELECT EMPLOYEE_ID,FIRST_NAME,SALARY, CASE WHEN SALARY>=10000 THEN 'S' WHEN SALARY>=9000 THEN 'A' WHEN SALARY>=7000 THEN 'B' WHEN SALARY>=5000 THEN 'C' ELSE 'D' END '评价', FROM t_employees;这段代码有什么问题
在这段代码中,最后一个逗号后面有一个多余的冒号,应该将逗号删除。正确的代码如下所示:
```
SELECT EMPLOYEE_ID, FIRST_NAME, SALARY,
CASE
WHEN SALARY >= 10000 THEN 'S'
WHEN SALARY >= 9000 THEN 'A'
WHEN SALARY >= 7000 THEN 'B'
WHEN SALARY >= 5000 THEN 'C'
ELSE 'D'
END '评价'
FROM t_employees;
```
此代码的功能是从表 t_employees 中选择 EMPLOYEE_ID、FIRST_NAME、SALARY 和评价字段,其中评价字段通过 CASE WHEN 语句根据 SALARY 的值进行计算。评价字段的值根据 SALARY 的大小被划分为 S、A、B、C、D 五个等级。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.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)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)