ODPS Python SDK and data analysis framework
Project description
Elegent way to access ODPS API. Documentation
Installation
The quick way:
pip install pyodps[full]
If you don’t need to use Jupyter, just type
pip install pyodps
The dependencies will be installed automatically.
Or from source code:
$ virtualenv pyodps_env
$ source pyodps_env/bin/activate
$ git clone <git clone URL> pyodps
$ cd pyodps
$ python setup.py install
Dependencies
Python (>=2.6), including Python 3+, pypy, Python 2.7 recommended
setuptools (>=3.0)
requests (>=2.4.0)
Run Unittest
copy conf/test.conf.template to odps/tests/test.conf, and fill it with your account
run python -m unittest discover
Usage
>>> from odps import ODPS
>>> o = ODPS('**your-access-id**', '**your-secret-access-key**',
... project='**your-project**', endpoint='**your-end-point**')
>>> dual = o.get_table('dual')
>>> dual.name
'dual'
>>> dual.schema
odps.Schema {
c_int_a bigint
c_int_b bigint
c_double_a double
c_double_b double
c_string_a string
c_string_b string
c_bool_a boolean
c_bool_b boolean
c_datetime_a datetime
c_datetime_b datetime
}
>>> dual.creation_time
datetime.datetime(2014, 6, 6, 13, 28, 24)
>>> dual.is_virtual_view
False
>>> dual.size
448
>>> dual.schema.columns
[<column c_int_a, type bigint>,
<column c_int_b, type bigint>,
<column c_double_a, type double>,
<column c_double_b, type double>,
<column c_string_a, type string>,
<column c_string_b, type string>,
<column c_bool_a, type boolean>,
<column c_bool_b, type boolean>,
<column c_datetime_a, type datetime>,
<column c_datetime_b, type datetime>]
DataFrame API
>>> from odps.df import DataFrame
>>> df = DataFrame(o.get_table('pyodps_iris'))
>>> df.dtypes
odps.Schema {
sepallength float64
sepalwidth float64
petallength float64
petalwidth float64
name string
}
>>> df.head(5)
|==========================================| 1 / 1 (100.00%) 0s
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-setosa
>>> df[df.sepalwidth > 3]['name', 'sepalwidth'].head(5)
|==========================================| 1 / 1 (100.00%) 12s
name sepalwidth
0 Iris-setosa 3.5
1 Iris-setosa 3.2
2 Iris-setosa 3.1
3 Iris-setosa 3.6
4 Iris-setosa 3.9
Command-line and IPython enhancement
In [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-setosa
Python UDF Debugging Tool
#file: plus.py
from odps.udf import annotate
@annotate('bigint,bigint->bigint')
class Plus(object):
def evaluate(self, a, b):
return a + b
$ cat plus.input 1,1 3,2 $ pyou plus.Plus < plus.input 2 5
Contributing
For a development install, clone the repository and then install from source:
git clone https://github.com/aliyun/aliyun-odps-python-sdk cd pyodps pip install -r requirements.txt -e .
If you need to modify the frontend code, you need to install nodejs/npm. To build and install your frontend code, use
python setup.py build_js python setup.py install_js
License
Licensed under the Apache License 2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for pyodps-0.10.1.1-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e52fa39c44670c175a04700db80012eaeb99bea39c1d23c0ddcd217608315638 |
|
MD5 | 573ce97ed93ba67e627f73c2a6d2a559 |
|
BLAKE2b-256 | 8c7f63f12387220da5c76e9e10a7c353f6af516a6dd515cd65be4653b65a4cf8 |
Hashes for pyodps-0.10.1.1-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cbe1b219f3391295527c9b88740388d776421d698ca21944c132c91c02715b50 |
|
MD5 | 7a81c8947036877b923acd7cc7e1feef |
|
BLAKE2b-256 | aa6e76393494d3d5ddaf4956cd3cc28a62b774222b8e3b36702e3fb22f6f1537 |
Hashes for pyodps-0.10.1.1-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89128508fb1b2173debe6c5d938552805423749757ab98b140945863cfa80c4e |
|
MD5 | 738461359307f2225fa6af104e1b504a |
|
BLAKE2b-256 | fbc113c29bdd117b20c1204d869753b4777e19bca6a026e9990f02cd2287890f |
Hashes for pyodps-0.10.1.1-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18837a33b43f5bfde5bdae22eed6403502532075f2f3736bc7421530ba8ea0b2 |
|
MD5 | 53a3adbee66b23097e08df4f5558e4a6 |
|
BLAKE2b-256 | 0ac46e2c5196d15d4947e564ef94ef36c221d3d97613da1ee9647dbd219176bb |
Hashes for pyodps-0.10.1.1-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 533d55671219bf7750cbebf3a5e40399dfcddfe5257d29d3d62eb1ae8e7e8499 |
|
MD5 | f273aa8c1334676d9ab062e5be168126 |
|
BLAKE2b-256 | bab26e56de926529953d6b7da0156ba63106deb061625fe4307da0c4fcd0ac13 |
Hashes for pyodps-0.10.1.1-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3c66ffff28cb5045ece9273ce00512346d1266602cdf9a5b1396001575dc2323 |
|
MD5 | 36691bdcbf1946c6b56ba89657cfa315 |
|
BLAKE2b-256 | 284e797edf2add8cae7141b041ed5140d028f2929d7e5411510fcecf5ae96a6a |
Hashes for pyodps-0.10.1.1-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15e7ea5630e4f33adc6037b38581026351c82f7e90aeb1f827e522e2104e198a |
|
MD5 | 3cd205568362b8e644b1e472214dfc62 |
|
BLAKE2b-256 | 3b3add35c1db9d9258e63044b01214cc3d92bbb2997a6c92cb684db67e9e18b8 |
Hashes for pyodps-0.10.1.1-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4f8e1e76f7d1b4f4bcef753feb3f24dc2eb871c06a2976cdc9ffae804310ff3a |
|
MD5 | 89c47df1d2f5661e66c7c8695481a222 |
|
BLAKE2b-256 | 27619a1b782d0d7aa077163a1b7c24c0804559636a1521b7c7b1e58556e023f6 |
Hashes for pyodps-0.10.1.1-cp35-cp35m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ccd2d25e612afd325f4749d865379e182a51f34fb19a38727ae66eba7e4852ca |
|
MD5 | 2448bcae53b62afc7017119ca15dfc7c |
|
BLAKE2b-256 | a5c34681878f26e8eac4f0df5d024123d20aac9259f20a3a71e2ac4460625958 |
Hashes for pyodps-0.10.1.1-cp35-cp35m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7ac19bff9839bf440ad29cd1e228bd3ddd8675f8b2b89d0310c29abe296715e5 |
|
MD5 | 13dbd02e79d58b18ef5806ce15799310 |
|
BLAKE2b-256 | 8623a63cd8a7ac226ccda9cbc6a10269311202eb13695947dc3fc5d48fbcec06 |
Hashes for pyodps-0.10.1.1-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe102977767065c90acb3bf2127a0a87329d0e67d72253977d5d163cbb93c9d8 |
|
MD5 | 3c1aca7de30adcf346169c9fd1ae09aa |
|
BLAKE2b-256 | 81334638f1cd8e826fad3f3d4b823543d92cee0dd78db47bc16713f4c82d7051 |
Hashes for pyodps-0.10.1.1-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c5b0b8b6cdfb05fd115cec3c05681b79433cc7b08677988d709731b737c7dc3 |
|
MD5 | 5d3d547a9d60c730a973334388b9e63b |
|
BLAKE2b-256 | 65077c626946e3109c92a68fa827c2ee0470b39c2a7d20639924554ab574c23b |
Hashes for pyodps-0.10.1.1-cp27-cp27m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3509d523d49e9ec8bef890ba353622d87a2f447162dfab5b7593e913745aad04 |
|
MD5 | 06baea40ec1973ea9fa8b6baa46111c5 |
|
BLAKE2b-256 | 523584fff281afb9b7b70cc598889dcf1a0875626fdd68f74ef9184d53e913fb |
Hashes for pyodps-0.10.1.1-cp27-cp27m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f865da75e625ec4b85b1e9d8360c57b1e2b211c39d2a3e8ba1606589680af6d |
|
MD5 | 7f0e502aedbd8e8949b1771fc05b145b |
|
BLAKE2b-256 | 4e14eaa4fd5eb26934c74c89a1a07e77bdf5128dc06ebfed7e627d604f16e4e9 |