推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
scalaer
V2EX  ›  Python

30M 左右的 parquet 文件, 转成 pandas 的 dataframe 存 mysql, 直接耗完 6 个 g 的内存?

  •  
  •   scalaer · Jan 18, 2019 · 1961 views
    This topic created in 2813 days ago, the information mentioned may be changed or developed.

    python 代码

    from pyarrow import parquet as pq
    
    
    fs = s3fs.S3FileSystem(...)
    
    path = ['s3a://.....']
    
    r = pq.ParquetDataset(_path, filesystem=fs)
    df = r.read().to_pandas()
    df.to_sql(....)
    

    相关的日志

    Jan 18 14:18:33  kernel: Out of memory: Kill process 3342 (python3) score 842 or sacrifice child
    Jan 18 14:18:33  kernel: Killed process 3342 (python3) total-vm:7950428kB, anon-rss:6945048kB, file-rss:0kB, shmem-rss:0kB
    
    1 replies  •  2019-01-18 14:49:24 +08:00
    scalaer
        1
    scalaer  
    OP
       Jan 18, 2019
    漏了点处理
    df['_time'] = df['time'].apply(lambda x: parse(x[:11] + " " + x[12:]).strftime("%Y-%m-%d %H:%M:%S"))
    df['bytes'] = df['request_size'] + df['response_size']
    df['bytes'] = df['bytes'].astype(int)
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2269 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 04:50 · PVG 12:50 · LAX 21:50 · JFK 00:50
    ♥ Do have faith in what you're doing.