我有下面的数据集。我想加上每个雇员的工资,这取决于雇员的月数_工作。为了如下面的数据集所示,名为“aaa”的emp工作了4个月,所以我想添加jan到Apr列,并将其存储在Total_usal列中。在
`import pandas as pd`
data=pd.read_csv("C:\\Users\\hp\\Desktop\\py\\p1.txt",delimiter=',')
df=pd.DataFrame(data)
print(df)
emp_id emp_name months_worked total_sal jan feb mar apr may \
0 1 aaa 4 NaN 2000 1 2.0 3 4.0
1 2 bbb 3 NaN 1 2 NaN 4 5.0
2 3 bbb 7 NaN 1 2 34343.0 4 NaN
3 4 bbb 12 NaN 1 2 33434.0 4 5.0
jun jul aug sep oct nov dec
0 5555.0 NaN 74343.0 8 9 10.0 NaN
1 643.0 7.0 NaN 9343 10 13431.0 12.0
2 6343.0 7.0 NaN 9 1043 11.0 12.0
3 NaN 7.0 8.0 9 1 NaN 12.0
输出:
^{pr2}$相关问题 更多 >
编程相关推荐