使用Pandas AWS Glue Python Shell作业

时间:2019-10-15 16:37:48

标签: python pandas aws-glue

AWS文档 https://docs.aws.amazon.com/glue/latest/dg/add-job-python.html

提及

  

运行Python Shell作业的环境支持以下内容   库:

     

...

     

pandas(必须通过python setuptools安装   配置,setup.py)

但是它没有提到如何进行安装。

如何在AWS Glue Python Shell作业中使用熊猫?

4 个答案:

答案 0 :(得分:1)

  1. 转到https://docs.aws.amazon.com/glue/latest/dg/add-job-python.html#create-python-extra-library。检查部分 要创建一个Python .egg或.whl文件,以说明“如何为python shell作业创建安装文件”
  2. 在setup.py文件中,添加第 - id: mib-resources uri: ${redirect.mib.uri} predicates: - Path=/** 行:
install_requires=['pandas==0.25.1']

我还编写了小的shell脚本来部署python shell作业,而无需手动步骤来创建egg文件并上传到s3并通过cloudformation进行部署。脚本会自动完成所有操作。 您可以在https://github.com/fatangare/aws-python-shell-deploy

中找到代码

答案 1 :(得分:0)

只是为了澄清Sandeep的答案,这是对我有用的

1 /忽略AWS文档

2 /创建一个包含以下内容的setup.py文件:

from setuptools import setup

setup(name="pandasmodule",
        version="0.1",
        packages=[],
        install_requires=['pandas==0.25.1']
    )

3 /在包含文件的文件夹中运行此命令:

python setup.py bdist_wheel

4 /将.whl文件上传到s3

5 /在您的Glue ETL作业中将“ Python库路径”配置为s3路径

您现在可以在Glue ETL作业中使用“ import pandas as pd

答案 2 :(得分:0)

无需执行任何操作,只需导入熊猫并开始使用它即可。

答案 3 :(得分:0)

AWS Glue 2.0支持熊猫-1.0.1 https://docs.aws.amazon.com/glue/latest/dg/reduced-start-times-spark-etl-jobs.html

因此,您可以在脚本中编写:import pandas。 如果要使用Glue中未提供的其他python模块,则可以下载.whl或.zip->将其存储在S3中->将其路径放在“ Python库路径”中的胶粘作业中,并在作业运行期间胶粘将做点子安装“ yourmodule”