for i in range(1, 7042):
if df['time'] < df['EndSeries']:
adding = df.iloc[i]
adding.column = df.column
adding['time'] += 1
df = df.append(adding, ignore_index=True)
我想完成这样的操作:判断每一行数据中time是否小于endseries,如果是,就把这一行复制下来添加到这个dataframe里边,并把time改成time+1
报错内容:
ValueError Traceback (most recent call last)
<ipython-input-81-12a8457f1209> in <module>
1 i = 1
----> 2 if df['time'] < df['EndSeries']:
3 adding = df.iloc[i]
4 adding.column = df.column
5 adding['time'] += 1
c:\users\swift\appdata\local\programs\python\python38\lib\site-packages\pandas\core\generic.py in __nonzero__(self)
1327
1328 def __nonzero__(self):
-> 1329 raise ValueError(
1330 f"The truth value of a {type(self).__name__} is ambiguous. "
1331 "Use a.empty, a.bool(), a.item(), a.any() or a.all()."
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().