【发布时间】:2016-04-20 21:43:35
【问题描述】:
如何在特定列中仅找到包含“NaN”的行?
我尝试使用此特定代码合并(左连接)两个数据帧并在“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
【问题讨论】:
-
知道哪一行产生错误会很有用
-
le 最后一个 "ln []: 车辆[vehicules['matricule'].isnull()]"
-
你需要发布原始数据来重现这一点,
vehicules.info()显示了什么 -
所有列都是非空对象。这是一个左连接(当我合并两个数据框时)。所以我在 vehicule_sql 列值中有“nan”。
-
我只是想找出两个数据帧之间的区别。
标签: python numpy pandas jupyter jupyter-notebook