How to load data into pandas from a large database?

后端 未结 2 1331
余生分开走
余生分开走 2021-01-14 21:40

I have a postgres database which contains time series data.The size of the database is around 1 GB.Currently to read data, this is what I do

import psycopg2
         


        
2条回答
  •  南笙
    南笙 (楼主)
    2021-01-14 22:38

    pd.read_sql() also has parameter chunksize, so you can read data from SQL table/query in chunks:

    for df in pd.read_sql("Select * from timeseries", conn, chunksize=10**4):
        # process `df` chunk here...
    

提交回复
热议问题