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.4-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cbd75bb57f320a22dbb41a68271a23f7bd0dd35600daa22361324e019c394caf |
|
MD5 | 69d4f26170afb3db7a40bc58f4998ae1 |
|
BLAKE2b-256 | 52a51a3aafb1d043781500fbd0cd1d9e05f10d128a010f51a4b29c9c399eed9d |
Hashes for pyodps-0.10.4-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 | d0672e428449a156b4cfe375a6016f7f0f49dc27f50d5b601acd0ed130ce458a |
|
MD5 | 20d865b03d29cf7b36949090b1bbe721 |
|
BLAKE2b-256 | 7914b5399c9f74330ab8c5ad39dad83bb64e2d9ca14a53487cb5399ff1031903 |
Hashes for pyodps-0.10.4-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59be6e30a24c78f1b00cf8fadef1b6631b9e1a9c1f0afb5eb3ade4c80a577e1a |
|
MD5 | 598d47ad1a814263dca08fb0afdc8853 |
|
BLAKE2b-256 | 31c402c7fb19a2dfb308deadb9bab8885d68044eb68b912bec89adc9c1e9ac5d |
Hashes for pyodps-0.10.4-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0877b724d6ae382d4034229ceb60357cd8f3e60ac11aeb8feb834ffbe144c0e5 |
|
MD5 | 3d8225b9763dde3b54a7200b5da2b5b0 |
|
BLAKE2b-256 | b7fdf1cdb0014ebbfd562c864d1f1af3b3a41d40260686ec6968340aa1912ce5 |
Hashes for pyodps-0.10.4-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 | 7b2f258343fcfdee85ce2985a48ea70f2563b7dcd863034702dc839d85241d48 |
|
MD5 | 2e9b539281aa1ad28dc92f8db30c74ed |
|
BLAKE2b-256 | 3a9716c77c621773a1dd4b928e9c5ae167f1f00c0b5cfdfcc16f3c9552d3a7b0 |
Hashes for pyodps-0.10.4-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d95ebf1e74642229d7befb7452e147a79496d7e4b8c4332de790a692164ebb2 |
|
MD5 | 0124fb903d3e9293d31d9c9119e7e292 |
|
BLAKE2b-256 | 93c6a49cc93ceb6665377efeffdbb23559e9b977c2177fb9a3b56148e4324d1c |
Hashes for pyodps-0.10.4-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 508c18091fdac9a655aba5a8956cdfd752299949c8143cb994ce810d022f50f4 |
|
MD5 | 9d5b7bfd3c3be359790632e496e2dfc5 |
|
BLAKE2b-256 | d305f51df0ae51b567526cd081183fb0cf92638f34a8484192945ef2826fe6a1 |
Hashes for pyodps-0.10.4-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 | e800f723f6c484ae77577d2568737b49f86e05cf0b88f0a92e0c4c9c41c9cf3c |
|
MD5 | 805cac98e0811bed45b15d81d5a5a6dd |
|
BLAKE2b-256 | a1d4d8d6ee408d426b8d2a0b24b4f513539a9b63a9911a763f3cdfc0e6221226 |
Hashes for pyodps-0.10.4-cp35-cp35m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a30c4fa7fbc62d182c709b0473d3a0a47683b3c0aba84dd2e3a1b324307a9513 |
|
MD5 | 928b2b9862d0c3edf7a50fe4eab5cbda |
|
BLAKE2b-256 | 0621c75756e4da692aeb2fd8e2fe663944655fd1e747bd038d34f28b806c774e |
Hashes for pyodps-0.10.4-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63c6857790da8738b78725060310dff5005689ad159216957f97624cc0a62640 |
|
MD5 | 35fe5db7685f8c13b887d8a9b4fd430d |
|
BLAKE2b-256 | 3c224affadfb5432570fde3a6e29f122f3e75fe8587725c336c9c6ac99aa535f |
Hashes for pyodps-0.10.4-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 | 300ba3be2f19ef7fb84ec77d316a59384d747110f830e1875e5b7be06fb81569 |
|
MD5 | d1b8a5f4508f321fbf3591172f959048 |
|
BLAKE2b-256 | bed8d8a3b521cffd0cedf82856d8ad4641056efe9cd5d977ce82e4348637f8fd |
Hashes for pyodps-0.10.4-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 119abafccbd54528ee1d6584b18cada2220e267b89aff77a39e4a8de5cfd5b98 |
|
MD5 | 2a74721b094a71bef1b364990c074964 |
|
BLAKE2b-256 | d5e23381bf6ef9efb9ee56bc692813fec4ebecff6574cc385be379733f83d27e |
Hashes for pyodps-0.10.4-cp27-cp27m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c64151a85a58c26701854633766b2174c729e0432d1661ad07c764eb0cd41db7 |
|
MD5 | a656cf91b23259e529e83cef0721efe5 |
|
BLAKE2b-256 | 91970c47c2b86dcf94dabed762389a954524ffd6f0fa4baddb00add5bdbe38e0 |
Hashes for pyodps-0.10.4-cp27-cp27m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bd59e7d2d54d871d1b5adda5a9bc5a1978a1bf8e2b5d425c42f0f84ec54cb3c0 |
|
MD5 | 4484b0f1eb2a2e794d459cfe3f9b48db |
|
BLAKE2b-256 | 8574e6f8e1659962247ccedea2e05c90024d7faaf3008b5e09a41933e856bb7e |
Hashes for pyodps-0.10.4-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 | 4ea1ee3a2a143b27148ab23431f5591237087561d34bedcb57c760faf101269c |
|
MD5 | 9a5e5352e1644e0449a46a47954a5b2b |
|
BLAKE2b-256 | 84fe7159725ede8188506f83acf0d33c32fc5e83d529cd4a3a11012560c7eeaf |