gpt4 book ai didi

Pandas read_sql 没有读取所有行

转载 作者:行者123 更新时间:2023-12-03 17:17:41 26 4
gpt4 key购买 nike

我通过 Pandas 的 read_sql 和外部应用程序 (DbVisualizer) 运行完全相同的查询。

DbVisualizer 返回 206 行,而 pandas 返回 178 行。

我曾尝试根据 How to create a large pandas dataframe from an sql query without running out of memory? 提供的信息通过夹头读取 Pandas 数据。 ,它没有改变。

这可能是什么原因以及解决方法?

查询:

select *
from rainy_days
where year=’2010’ and day=‘weekend’

列包含:日期、年份、工作日、当天的降雨量、温度、地理位置(每个位置的行)、风测量值、前一天的降雨量等。

确切的python代码(减去连接细节)是:
import pandas
from sqlalchemy import create_engine

engine = create_engine(
'postgresql://user:pass@server.com/weatherhist?port=5439',
)

query = """
select *
from rainy_days
where year=’2010’ and day=‘weekend’
"""
df = pandas.read_sql(query, con=engine)

最佳答案

https://github.com/xzkostyan/clickhouse-sqlalchemy/issues/14
如果你使用纯 engine.execute 你应该手动关心格式

关于 Pandas read_sql 没有读取所有行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35841600/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com