Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
258 views
in Technique[技术] by (71.8m points)

如何在dataframe中删除某行当某列值为nan时?

clipboard.png
just my luck 的值为nan时,删除Jack Matthews和Micheal Phillips这两行


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

两种方法:
1、删除just my luck为NaN的行

    indexs = list(df[np.isnan(df['just my luck'])].index)
    df = df.drop(indexs)

2、获取just my luck不为NaN的行

    df = df[np.isnan(df['just my luck']) == False]

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...