pandas-assign函數


盡管df["column"]方式新增一列數據已經很方便,但是在不需要實際生成該列,又可以調用某列數據時,df.assign()方法更具優勢。

創建數據:

新增列:df["column"]

新增列:df.assign()

assign always returns a copy of the data, leaving the original DataFrame untouched.

使用assign方法返回數據的副本,原始數據不受影響。

You can create multiple columns within the same assign where one of the columns depends on another one defined within the same assign.

在同一個assign中創建多列,下一列數據創建過程可以直接調用剛生成的上一列。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM