仅查找特定列中包含“NaN”的行?

时间:2016-01-15 10:08:32

标签: python numpy pandas jupyter jupyter-notebook

如何才能找到特定列中包含“NaN”的行?

我尝试使用此特定代码合并(左连接)两个dataFrame,并在“matricule”列中找到包含“NaN”的 ONLY 行。

ln []: import pandas as pd
import datetime as dt
import numpy as np
from datetime import datetime
from datetime import timedelta
from sqlalchemy import create_engine

ln []: vehicule_xls = pd.read_excel("vehicule.xls")
vehicule_xls

ln []: vehicule_sql = pd.read_sql_query('select * from vehicule ', con=engine)
vehicule_sql

ln []: vehicules = pd.merge(vehicule_xls, vehicule_sql, left_on='Immat', right_on="matricule", how='left', indicator='Indicator')

ln []: vehicules[vehicules['matricule'].isnull()]

但是我在最后一个命令上遇到了这个错误。

TypeError: data type not understood

1 个答案:

答案 0 :(得分:-1)

您可以获取二进制向量,指示特定行在感兴趣的列中是否具有nan,如下所示

fltr = vehicules['matricule'].isnull()

然后,您可以使用

提取感兴趣的子集
subset = vehicules[fltr]
相关问题