简体   繁体   English

列出一系列缺失行的唯一标识符

[英]List unique identifier of missing rows in a series

Is it possible to return the row number of missing values within a given series? 是否可以返回给定系列中缺少值的行数?

    Name  Age
    Fred  25
    John  38
    Chris

I want to return the row number or some unique identifier of any rows where 'Age' is missing. 我想返回行号或缺少“年龄”的任何行的某些唯一标识符。 ie Chris 即克里斯

Use: 采用:

df = pd.DataFrame({'Age': [25.0, 38.0, np.nan]}, index=['Fred', 'John', 'Chris'])
print (df)
        Age
Fred   25.0
John   38.0
Chris   NaN

m = df['Age'].isnull()
print (df.index[m].tolist())
[Chris]

您可以执行df.index[pd.isnull(df['Age'])]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM