pandas - 向前查找没有 NaN 的值,就像 Series.asof
问题描述
我知道 Series.asof 是 .HoweverThe last row without any NaN is taken
我想得到The first row without any NaN is taken
。有什么办法可以解决吗?
解决方案
您可以通过以下方式完成此操作:
ser[~ser.isnull()].iloc[0]
或者
ser[ser.isnull().ne(True).idxmax()]
或者使用更惯用的first_valid_index
:
ser[ser.first_valid_index()]
推荐阅读
- bash - 内联 unix 命令作为文件名
- module - 内部表示未隐藏在 f# 模块中
- security - 如何在 scapy 的 tls 中发送原始数据?
- karate - 空手道 API 测试 - 从响应中删除重复值并将其与新响应进行比较
- java - Google 应用引擎 没有与此 URL 匹配的处理程序
- python-3.x - 没有提供渐变
- highcharts - Highcharts - 向箱线图添加边框半径
- flutter - Navigator.removeRoute & Navigator.removeRouteBelow
- autodesk-forge - AutodeskForge 支持哪个版本的 Revit?
- c++ - 使用带有 Windows Active Directory 的 LDAP 进行用户身份验证 (Windows Server 2016)