【问题标题】:How to read S3 part files into pandas dataframe如何将 S3 部分文件读入 pandas 数据框
【发布时间】:2017-06-05 19:55:13
【问题描述】:

我已将数据从 redshift 卸载到 S3,卸载后我得到了 xx_0000_part_00 多个文件。

现在我想将这些文件读入 pandas 数据框。

我该怎么做?

谢谢, 索姆

【问题讨论】:

    标签: python pandas amazon-redshift


    【解决方案1】:

    您必须使用

    将文件从 s3 导入本地或 ec2

    aws s3 cp

    命令。在本地获得文件后,只需通过 pandas 库读取它。

    import pandas as pd
    df = pd.read_csv('/file-path/filename')
    

    PS - S3 部分文件只是一个带有您选择的分隔符的常规 csv 文件。

    如果我做了一个错误的假设,请发表评论,我会重新调整我的答案。

    【讨论】:

      【解决方案2】:

      如果你想从redshift获取数据到pandas(或从pandas获取数据到redshift),只需使用这个包:

      https://github.com/agawronski/pandas_redshift

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-03-23
        • 2019-11-25
        • 1970-01-01
        • 2017-09-25
        • 2020-08-27
        • 2017-07-27
        • 1970-01-01
        • 2019-10-13
        相关资源
        最近更新 更多