Python panda增量CSV像元值

yc0p9oo0  于 2022-12-06  发布在  Python
关注(0)|答案(1)|浏览(145)

使用python语言和panda,当我的if语句为真时,我如何操作一个现有的CSV单元格,使其单元格值总是加1?

>while True
>   if xxx = TRUE
>      "open existing CSV and take the value of A1 and increment by +1"
pwuypxnk

pwuypxnk1#

试试这个

import pandas as pd
A = list(range(10))
B = [a%3==0 for a in A]
df = pd.DataFrame({'A':A, 'B':B})
df['A+1 if B True'] = df['A'] + df['B'] * 1

相关问题