簡體   English   中英

Function 過濾和應用 python 中的計算錯誤

[英]Function to filter and apply calculation error in python

導入 pandas 作為 pd

def bonus_calculation(數據框):

df2 = pd.read_csv("C:\\Users\\ThisI\\employees_update.csv")

active_employees['bonus'] = df2[df2["end_date"].isnull()].loc[:, "salary"] * 1.2

return active_employees

獎金計算(active_employees)

我收到此錯誤消息::7:SettingWithCopyWarning:試圖在 DataFrame 的切片副本上設置值。 嘗試改用 .loc[row_indexer,col_indexer] = value

請參閱文檔中的警告: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy active_employees['bonus'] = df2[df2 ["end_date"].isnull()].loc[:, "salary"] * 1.2

有人可以幫我嗎?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM