|
楼主 |
发表于 2022-7-1 19:54:00
|
显示全部楼层
不太行。。。
我这样写,报错了,,我想把b里对应者就是a中的行,b中哪个元素是sb ,那a中那一行对应的值全部*2
- import pandas as pd
- import numpy as np
- a = pd.DataFrame(np.arange(100).reshape(10,10))
- print(a)
- b = ["sb","sb","sb","sb","sb","1",'2',"sb","sb","sb",]
- c = pd.DataFrame(b)
- index__ = []
- for i in c.index:
- if c.iloc[i] == "sb":
- index__.append(i)
- print(index__)
复制代码
Traceback (most recent call last):
File "/home/victor/catkin_ws/src/test1/src/my.py", line 11, in <module>
if c.iloc == "sb":
File "/home/victor/anaconda3/lib/python3.9/site-packages/pandas/core/generic.py", line 1527, in __nonzero__
raise ValueError(
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all(). |
|