0
我使用输入SQL查询在python上构建了一个数据框。 AFER这我的名字我的专栏,并确保它是很好的与NaN值隔离柱:在pandas python中比较dataframe列和单个值
cursor.execute(raw_input("Enter your SQL query: "))
records = cursor.fetchall()
import pandas as pd
dframesql = pd.DataFrame(records)
dframesql.columns = [i[0] for i in cursor.description]
问题是当我想要的行数的数据与行的数据帧总数比较后:
dframelines = len(dframesql)
dframedesc = pd.DataFrame(dframesql.count())
当我试着使用dframelines比较dframedesc,我得到一个错误
nancol = []
for line in dframedesc:
if dframedesc < dframelines:
nancol.append(line)
ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
提前感谢!