python - ValueError 递归但不是在开始时:
问题描述
我在下面的代码中收到以下错误。
ValueError:Series 的真值不明确。使用 a.empty、a.bool()、a.item()、a.any() 或 a.all()。
def calculatepct(gems,pct):
if pct < 0:
pct = 0
not_in_dictionary = True
for child in acap1051.itertuples():
if child.gems == gems:
not_in_dictionary = False
if child.parent_gems_ in all_children['gems'].values:
mask1 = all_children[all_children["gems"] == child.parent_gems_]
if all_children.loc[mask1.index.item()]['calculated'] == -1:
calculatepct(child.parent_gems_,all_children.loc[mask1.index.item()]['calculated'])
该代码适用于两个周期,但在此行之后出现值错误:
mask1 = all_children[all_children["gems"] == child.parent_gems_]
解决方案
推荐阅读
- python - 从文本中提取 x 和 y 数据
- java - Java LocalDate 在保存到 MySQL 数据库时存储为半随机天数
- excel - 在 Excel 中对另一个唯一值中的唯一值进行排序
- r - 即使所有组都是空的,也显示空组
- pandas - 如何在熊猫中将负数转换为 DateTime 格式?
- c++ - 如何使用 rand 随机化模拟点击
- android - Google Sceneform – 是否已弃用?有替代品吗?
- python - 如何在 Python 中创建日期范围并转换为 DataFrame
- azure-active-directory - 如何使用 InTune 设备配置策略来管理 AzureAD 域用户的密码复杂性
- mysql - 尝试使用工作台将 .csv 导入 mySQL,但只导入 6 行?