如何根据条件对 pandas 数据框进行切片?

Hug*_*ugo 6 python pandas

当我使用以下代码时:

frioMurteira = data.loc[(data["POM"] == "Murteira" & data["TMP"] > 7.2), ["DTM","TMP"]]
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

cannot compare a dtyped [float64] array with a scalar of type [bool]
Run Code Online (Sandbox Code Playgroud)

你可以帮帮我吗?

谢谢

Alv*_*tes 14

我认为您的牙套有错误,请尝试以下操作:

frioMurteira = data.loc[(data["POM"] == "Murteira") & (data["TMP"] > 7.2), ["DTM","TMP"]]
Run Code Online (Sandbox Code Playgroud)