python - 如何重写 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") 的“纬度”?
解决方案
推荐阅读
- c# - 在 C# 中的 Xml 签名中配置 TSA
- unix - 子线程如何从其 pthread_create() 的启动函数返回?
- swift - 全局快捷键不起作用 MacOS - HotKey
- git - 将一个存储库的某些特定文件夹获取到不同路径的另一个存储库。频繁获取更新
- python - 从图像中删除带有黑色边框的白色文本
- blockly - 在 Angular 应用程序中找不到 Blockly Generator 功能
- sass - 在@mixin-name 中为动态@include 插值
- reactjs - 在 map 函数中使用三元组
- go - 从 `metrics:` 字段标签配置 Prometheus Go 客户端
- node.js - peerjs 事件“呼叫”有时不会启动