簡體   English   中英

我正在嘗試對我的 dataframe 中的一列應用 function,嘗試使用 lambda 將價格列中的條目除以 100 function

[英]I m trying to do an apply function over a column in my dataframe, trying to divide the entries in the column Price by 100 using lambda function

car_data["Price"]= car_data["Price"].apply(lambda x:x/100))
                                                     ^
SyntaxError: invalid syntax


car_data["Price"].dtype
dtype('int32')

這是什么錯誤

任何語法錯誤都意味着您在使用編程語言編寫時必須遵守的基本規則有問題。 在您的情況下,第一個語句的末尾有很多括號。 所以應該是:

car_data["Price"]= car_data["Price"].apply(lambda x:x/100)

暫無
暫無

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

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