如何在pandas中显示行或选择行,其中任何列包含NAN

时间:2015-10-08 09:46:36

标签: python-2.7 pandas

我的表:

    $sql  = "SELECT _t.*, _t1.*, _t2.*";
    $sql .= "FROM _test as _t ";
    $sql .= "LEFT JOIN _test1 as _t1 ";
    $sql .= "ON _t.test_column=_t1.test_column ";
    $sql .= "LEFT JOIN _test2 as _t2 ";
    $sql .= "ON _t.test_column = _t2.test_column ";
    $sql .= "WHERE _t.test_column ='test_value'";

我想选择或显示第一行?我应该怎么做。

Ram  Shyam Kamal
2    nan   4
1    2     5
8    7     10

1 个答案:

答案 0 :(得分:0)

df成为您的数据框,您可以:

df = df[df.isnull().any(axis=1)]

返回:

   Ram  Shyam  Kamal
0    2    NaN      4