Package: pyodps
Elegent way to access ODPS API.DocumentationInstallationThe quick way:pip install pyodps[full]If you don’t need to use Jupyter, just typepip install pyodpsThe dependencies will be installed automatically.Or from source code:$virtualenvpyodps_env$sourcepyodps_env/bin/activate$pipinstallgit+https://github.com/aliyun/aliyun-odps-python-sdk.gitDependenciesPython (>=2.7), including Python 3+, pypy, Python 3.7 recommendedsetuptools (>=3.0)Run Testsinstall pytestcopy conf/test.conf.template to odps/tests/test.conf, and fill it
with your accountrunpytest odpsUsage>>>importos>>>fromodpsimportODPS>>># Make sure environment variable ALIBABA_CLOUD_ACCESS_KEY_ID already set to Access Key ID of user>>># while environment variable ALIBABA_CLOUD_ACCESS_KEY_SECRET set to Access Key Secret of user.>>># Not recommended to hardcode Access Key ID or Access Key Secret in your code.>>>o=ODPS(>>>os.getenv('ALIBABA_CLOUD_ACCESS_KEY_ID'),>>>os.getenv('ALIBABA_CLOUD_ACCESS_KEY_SECRET'),>>>project='**your-project**',>>>endpoint='**your-endpoint**',>>>)>>>dual=o.get_table('dual')>>>dual.name'dual'>>>dual.table_schemaodps.Schema{c_int_abigintc_int_bbigintc_double_adoublec_double_bdoublec_string_astringc_string_bstringc_bool_abooleanc_bool_bbooleanc_datetime_adatetimec_datetime_bdatetime}>>>dual.creation_timedatetime.datetime(2014,6,6,13,28,24)>>>dual.is_virtual_viewFalse>>>dual.size448>>>dual.table_schema.columns[<columnc_int_a,typebigint>,<columnc_int_b,typebigint>,<columnc_double_a,typedouble>,<columnc_double_b,typedouble>,<columnc_string_a,typestring>,<columnc_string_b,typestring>,<columnc_bool_a,typeboolean>,<columnc_bool_b,typeboolean>,<columnc_datetime_a,typedatetime>,<columnc_datetime_b,typedatetime>]DataFrame API>>>fromodps.dfimportDataFrame>>>df=DataFrame(o.get_table('pyodps_iris'))>>>df.dtypesodps.Schema{sepallengthfloat64sepalwidthfloat64petallengthfloat64petalwidthfloat64namestring}>>>df.head(5)|==========================================|1/1(100.00%)0ssepallengthsepalwidthpetallengthpetalwidthname05.13.51.40.2Iris-setosa14.93.01.40.2Iris-setosa24.73.21.30.2Iris-setosa34.63.11.50.2Iris-setosa45.03.61.40.2Iris-setosa>>>df[df.sepalwidth>3]['name','sepalwidth'].head(5)|==========================================|1/1(100.00%)12snamesepalwidth0Iris-setosa3.51Iris-setosa3.22Iris-setosa3.13Iris-setosa3.64Iris-setosa3.9Command-line and IPython enhancementIn [1]: %load_ext odps

In [2]: %enter
Out[2]: <odps.inter.Room at 0x10fe0e450>

In [3]: %sql select * from pyodps_iris limit 5
|==========================================|   1 /  1  (100.00%)         2s
Out[3]:
   sepallength  sepalwidth  petallength  petalwidth         name
0          5.1         3.5          1.4         0.2  Iris-setosa
1          4.9         3.0          1.4         0.2  Iris-setosa
2          4.7         3.2          1.3         0.2  Iris-setosa
3          4.6         3.1          1.5         0.2  Iris-setosa
4          5.0         3.6          1.4         0.2  Iris-setosaPython UDF Debugging Tool#file: plus.pyfromodps.udfimportannotate@annotate('bigint,bigint->bigint')classPlus(object):defevaluate(self,a,b):returna+b$ cat plus.input
1,1
3,2
$ pyou plus.Plus < plus.input
2
5ContributingFor a development install, clone the repository and then install from
source:git clone https://github.com/aliyun/aliyun-odps-python-sdk.git
cd pyodps
pip install -r requirements.txt -e .If you need to modify the frontend code, you need to installnodejs/npm. To build and install your
frontend code, usepython setup.py build_js
python setup.py install_jsLicenseLicensed under theApache License
2.0