我想比较2值的结果,但我不知道这里发生了什么。熊猫如果/真理陈述值错误
# Read items into Dataframe and count the number of rows there is.
df_csv = pandas.read_csv('dataset.csv', index_col=False, header=None)
print(len(df_csv.index))
# Creating Session to count the number of rows there are in the SQL file
Session = sessionmaker(bind=engine)
session = Session()
# Getting count
meta = MetaData()
table_to_count = Table('Database count details', meta, autoload=True,
autoload_with=engine)
df_sql = session.query(func.count(table_to_count)).scalar()
print(df_sql)
# Perform logic test
if df_csv <= df_sql:
print("sql is less than csv")
elif df_csv >= df_sql:
print("CSV is current with sql")
不过,我得到的错误是ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
我提到了一些计算器其他问题,但我仍然没能解决这个问题。你怎么看?
编辑
print(len(df_csv.index))
将返回值3984
。
print(df_sql)
将返回3982
所以我想这些2个数字进行比较。
'if'不明白对数组布尔操作,因为错误状态一样,如果你有1或你阵列中的所有积极条件,所以你需要决定你是否正在寻找1个或更多的正面匹配,例如'if(df_csv <= df_sql).all():'等等。 – EdChum
你认为'df_csv <= df_sql'是什么意思? – Goyo
@Goyo我编辑了我的问题。希望能帮助到你? –