[問題] Pandas 指定條件修改內容

作者: ctr1 (【積π】)   2020-03-10 09:32:35
在Pandas中我想要修改
將紅色的部分改為2019
條件想要用 month = 'Nov' or month = 'Dec'
不知道各位大大是否有較好的寫法呢
先謝謝各位了
year month day time cl SessionID user user_id
2020 Nov 30 19:16:22 cl ftp[4504]: USER sc
2020 Nov 30 19:16:22 cl ftp[4509]: USER sc
2020 Nov 30 19:16:26 cl ftp[4551]: USER sc
2020 Nov 30 19:16:36 cl ftp[4597]: USER ace
2020 Nov 30 19:16:39 cl ftp[4611]: USER yA
2020 Dec 31 23:59:01 cl ftp[11667]: USER sc
2020 Dec 31 23:59:01 cl ftp[11670]: USER nx
2020 Dec 31 23:59:02 cl ftp[11674]: USER sc
2020 Dec 31 23:59:03 cl ftp[11675]: USER sc
2020 Dec 31 23:59:03 cl ftp[11678]: USER sc
2020 Dec 31 23:59:07 cl ftp[11683]: USER sc
2020 Jan 1 00:00:01 cl ftp[12183]: USER sc
2020 Jan 1 00:00:01 cl ftp[12185]: USER ap
2020 Jan 1 00:00:02 cl ftp[12196]: USER ni
2020 Jan 1 00:00:02 cl ftp[12193]: USER isu
作者: aassdd926 (打東東)   2020-03-10 09:36:00
用 loc
作者: Pieteacher (pieteacher)   2020-03-10 11:20:00
df[df.month.isin(‘Dec’,’Nov’)][‘year’]=2019
作者: TitanEric (泰坦)   2020-03-10 12:51:00
推樓上
作者: cuteSquirrel (松鼠)   2020-03-10 14:53:00

Links booklink

Contact Us: admin [ a t ] ucptt.com