首页 > 解决方案 > 如何重写 df["column_A"]` 以仅返回另一列的值等于 '3' 的 column_A 的值?

问题描述

我对python、pandas等很陌生。

语境:

我的数据框“listCoords”如下所示:

Date/Time              Lat                   Lon                   Threat
2019-01-20 06:00:00,   -10.792921094981814,  20.191716715339687,    2
2019-01-20 06:05:00,   -11.798684405083584,  21.162881454312586,    3
2019-01-20 06:05:00,   -10.798684405083584,  19.162881454312586,    1
2019-01-20 06:05:00,   -11.798684405083584,  20.145381454312586,    1

目前我使用所有“纬度”值 per: lat = listCoords["Lat"]。现在我想要一个lat_threat = listCoords["Lat"]for where listCoords["Threat"]=="3"

我如何重新编写lat = listCoords["Lat"],以便仅获得 where (Threat=="3") 的“纬度”?

标签: pythonpandas

解决方案


推荐阅读