【问题标题】:Issues with pytest for Bigquery DataframeBigquery Dataframe 的 pytest 问题
【发布时间】:2021-10-21 17:44:50
【问题描述】:

在本地,我可以在 Notebook 和 .py 文件中使用 Bigquery 获取数据框。

然而, 在使用 pytest 进行测试时

bq=bigquery.Client(project='xyz')
query_string="SELECT *FROM <table_name>"
df = bq.query(str(query_string)).result().to_dataframe()
assert df

它将通过一个错误

@Final def 非零(自我): 引发 ValueError(

  f"The truth value of a {type(self).__name__} is ambiguous. "
    "Use a.empty, a.bool(), a.item(), a.any() or a.all()."
)

E ValueError:索引的真值不明确。使用 a.empty、a.bool()、a.item()、a.any() 或 a.all()。

/opt/conda/lib/python3.7/site-packages/pandas/core/indexes/base.py:2574: ValueError

我们如何隐藏这个错误信息或者它是 pytest 的一些错误?

【问题讨论】:

    标签: python pandas google-bigquery pytest pytest-django


    【解决方案1】:

    您可以在数据帧中使用 a.empty、a.bool()、a.item()、a.any() 或 a.all()。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-06
      • 1970-01-01
      相关资源
      最近更新 更多