我在做这样的事情
def searchCassanadra(self):
# Iterate over every pokemon
for x in self.pokemon_list:
# Query
query = session.execute("SELECT pokemon_id FROM ds_pokedex.pokemon where pokemon_id=" + repr(x))
上面的代码返回给我<class 'cassandra.cluster.ResultSet'>
我如何检查这个ResultSet
是空的还是从Cassandra填充的?在
我正在用python编写代码。 抱歉问新手的问题。在
如果我试着
^{pr2}$我得到了这个错误
ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
谢谢你的帮助。在
看起来您的
query._current_rows
属性是pandas数据帧,因此当您尝试运行query.current_rows
时,无论ResultSet
是否为空,都会引发一个ValueError。在从
ResultSet
的Cassandra Driver docs中,我们看到current_rows
函数寻找_current_rows
属性的存在:如果上面的
^{pr2}$self._current_rows
是pandas数据帧,则始终返回ValueError。例如:因此,要检查
ResultSet
中的pandas DataFrame是否包含数据,可以执行以下操作:(注意:我不知道您的
session.row_factory
是什么样子,但我假设它是从Cassandra返回的行创建pandas数据帧,类似于this答案)相关问题 更多 >
编程相关推荐