ODPS Python SDK and data analysis framework
Project description
Elegent way to access ODPS API. Documentation
Installation
The quick way:
pip install pyodps[full]
To integrate with Mars:
pip install pyodps#egg=pyodps[mars]
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.5-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d7675d3b92701dee94e034a9ead0a64193c8a3456ef9970e5f38ae43219b0219 |
|
MD5 | 2cf1f294fd5d7e5a336d6fb568cb4ca2 |
|
BLAKE2b-256 | 90cb978334f338932d33f0225a795028b031c9d13f3ad52a753ef9fd1e0a99b3 |
Hashes for pyodps-0.10.5-cp38-cp38-macosx_10_9_x86_64.macosx_10_9_intel.macosx_10_10_intel.macosx_10_10_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c8be1a4a0f813c56de3ba5fbce059bbd82d97c31eaf333e215a09f206f80ca5 |
|
MD5 | 3d26c23d4f1d7d097f109d5943f2af06 |
|
BLAKE2b-256 | df1fceff0284ee5558884d50b5b9f740046abb4a40a2f95e334ea3d2d2a0ac6d |
Hashes for pyodps-0.10.5-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8051b686f9efe48bb395ab42a828b359a4f630aa676df9db4fbebdecf624d6f6 |
|
MD5 | f54e9261b5f0ce19145bf25a8f419141 |
|
BLAKE2b-256 | f44b3f47452438a9e2c7e04a1ad9db3232badf9dabd76a0dd4448aea255359d3 |
Hashes for pyodps-0.10.5-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5238e5e79ccc38a3bea4fcd303e6ce961f401be04ec07cd3778ddc74d6bac14d |
|
MD5 | 30e4c467a3d9913b409b39f4d2bb972f |
|
BLAKE2b-256 | 666940951fef37074f798c2bc8802b4770c1107e953ee5a7c022414b37232b17 |
Hashes for pyodps-0.10.5-cp37-cp37m-macosx_10_9_x86_64.macosx_10_9_intel.macosx_10_10_intel.macosx_10_10_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1cdafbceb10bf15c65db4c6c5b47dd78f43fec3955437820476b215b5a39bd0 |
|
MD5 | 54ea2f3857cfaadcab0c872f1ca73c19 |
|
BLAKE2b-256 | 546a15ac42f245d4fd3319ab183d8dc6e3421d23b69d2682e38189330ea99059 |
Hashes for pyodps-0.10.5-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7782ae2a88f2b37f6bdd0f300329b4e7eb540328ed96f2b603beb52b80441401 |
|
MD5 | 50c509d85c2682b7bf5073b71af93c5a |
|
BLAKE2b-256 | b5233ed74c72d2f2664a5b3a69ef34a2a08448c1c0808315d0fd58144bbaf66c |
Hashes for pyodps-0.10.5-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9248dc1fe5e3e51960358c1d374bcbb90d48049943747450c9140f25811a8031 |
|
MD5 | 8a43301b6ce1025f8f51d677caf8ce26 |
|
BLAKE2b-256 | c59ce60873a403c16533575e42ea95ece12e9c5abb59c83e48378eb5bb707114 |
Hashes for pyodps-0.10.5-cp36-cp36m-macosx_10_9_x86_64.macosx_10_9_intel.macosx_10_10_intel.macosx_10_10_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 105d638947dcd35f62b55c2f1d9d08b2573014639c131c0b43a2d16758db3a56 |
|
MD5 | febd2f082bcf3b61892821802f99f58d |
|
BLAKE2b-256 | a49da7afbb4d238d4007c62304c256f6148063e227676f498d97b62235c0b81f |
Hashes for pyodps-0.10.5-cp35-cp35m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0facbec246c7c5da378844a47baadcbb4bd4626047e035210c17d40a448722f0 |
|
MD5 | 541999e61626fc92fb569b70179289cb |
|
BLAKE2b-256 | e957d6570547f07a5ceff4e540c5a2baad70f74739b4a2920b94acaba8c14533 |
Hashes for pyodps-0.10.5-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6371415be40352bffe6a770772b78d673269f5017a15d23e98e6a53b881a3cf8 |
|
MD5 | 7796e60bfda12465efb70d4c3cf096cf |
|
BLAKE2b-256 | 8482741e50b467b95739c54d69eaf5f712563aa05a0d1c7b7a66e18d6424d25c |
Hashes for pyodps-0.10.5-cp35-cp35m-macosx_10_9_x86_64.macosx_10_9_intel.macosx_10_10_intel.macosx_10_10_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0f2b09e2c410dde5e4869a955abeb44d1b5eaab862aec10a279815b6304d46d |
|
MD5 | 59073e75538e2de8088306cd7826de5a |
|
BLAKE2b-256 | 0d9be347fa797719996970b96db5032773ce42529c82439c878dac06769ff2f0 |
Hashes for pyodps-0.10.5-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dfdd3b70195db612bb0b99d613f5465249c2e27dbed6f72e2f0cfade51dd7b33 |
|
MD5 | e8dc7f9fbf238927e927adb8ac302794 |
|
BLAKE2b-256 | aea334680a36020eb7c3c301a3cfcb3ed09cb3fb904241de1932207b478cd83f |
Hashes for pyodps-0.10.5-cp27-cp27m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b995179c318ead27a3e4031ca1dc4fa15c13318be8a76ab537c1ee785b2e770d |
|
MD5 | 910c162a5d5957a23f95ff3230ef2be7 |
|
BLAKE2b-256 | 7c6151a6ced04dc7d6469020b8559a37cabb001069305e81ab7d852de1eee495 |
Hashes for pyodps-0.10.5-cp27-cp27m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 678ccb98e47f7fbea71ed3c2d1ef0c5592b1c6f7b579149cc8a996f02146810c |
|
MD5 | e65adb188013ec77e81b991b1819b2a1 |
|
BLAKE2b-256 | 4870f16147996a46ae1ce460581c67935125448c77598f10607bf1fdc33de1d8 |
Hashes for pyodps-0.10.5-cp27-cp27m-macosx_10_9_x86_64.macosx_10_9_intel.macosx_10_10_intel.macosx_10_10_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 32b2996395215392552c06b2d775ef16295841426fde1c12a9e7e7df4bf6c885 |
|
MD5 | a2e0b7845fa9d1bc7e6060a9a8ab9b79 |
|
BLAKE2b-256 | bdec446c90003ea000d529b6da5b3d1c3e62216a02464570b8a9f59d34afdd5d |