【发布时间】:2021-06-15 13:48:04
【问题描述】:
我想选择 x 中不包含 0 的产品。 输入:
test = pd.DataFrame(
[
['a', 0],
['a', 3],
['a', 4],
['b', 3],
['b', 2],
['c', 1],
['d', 0]
]
)
test.columns = ['product', 'x']
test.query("select distinct (product) where x not in (0) ")
预期结果: 乙,丙
如何在 pandas 和 SQL 中做到这一点?
【问题讨论】: