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.6-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 25567ef511fdd04a0fd6a3f5ce7cc9a8f64050c9d4b98e5e51492f9412608a9d |
|
MD5 | beddc13b3beddb3cc69cc2a02e1b7d4a |
|
BLAKE2b-256 | 035094fc6ec165545825f25a90e55784af0f25ec3ae06ab1629305b52a264147 |
Hashes for pyodps-0.10.6-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 | 2b6dd7cb213736e04eef1793622441025a7b3aa8918bfaf07d9a0d790904d8cb |
|
MD5 | 65fcebe97061ad9ab73e25d4277f1ce5 |
|
BLAKE2b-256 | ba69d0e1f26a55ee3dd1d3bbfd99bf4ef06e3976fe9ffc1432c79c45db50bbf6 |
Hashes for pyodps-0.10.6-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | af4e69023da69689171b08aea3cb2b50a7017333d838eb25e6474df0db01dd6a |
|
MD5 | 23eabd01be45a372176ed0dfbb2e713b |
|
BLAKE2b-256 | b26c8af0cc9c39264669c7732e5f887f956fe8971d84b1fe8cbb290dd506da2c |
Hashes for pyodps-0.10.6-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c2fa6125e1377c102d21086278d4da0a9e0e670d62e88d78796770052483f97b |
|
MD5 | 1cdcfd903bf830ccccefb39fbc6f91d8 |
|
BLAKE2b-256 | 7790cdce1828bc177b810e0f6d0919727cd82ff3eaef1fad766383ccbd95c029 |
Hashes for pyodps-0.10.6-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 | eb1abd6518716fe8f59a9d16a3678d76150610e90f2bcb53e596c29557973034 |
|
MD5 | 0b18ebc09980da8b0936e91fcfc09af6 |
|
BLAKE2b-256 | eeb244a8b04e3fc2bfa0c4f5b9b3eceb0040659bd11cf960519f24f719a483b7 |
Hashes for pyodps-0.10.6-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | be9bdfeec91bfa97753b4c279777448d5dd53fefa1f0b91392588aa363d763a2 |
|
MD5 | 76960807bc23190c25e4dfd9a7d38ced |
|
BLAKE2b-256 | 0b7ae7f6bae38b7a197f6d4913bdbd0e3970f76bb4add06281c3a6a785a23492 |
Hashes for pyodps-0.10.6-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 46d5ff5a84799a3c60079a34d6fa64b4de5d397996fc15d916865a34226d1ab7 |
|
MD5 | 175ba7372979e6f760a10530c94bfd70 |
|
BLAKE2b-256 | 43e851876a27c3b67298a9d9cc208f0f8d94468990906e9a0afc06817cc515f4 |
Hashes for pyodps-0.10.6-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 | d4008fc44afad920f2cba8b32425535caddd510318313c6b32840aa3ad6cb01f |
|
MD5 | bc3caf35725ac3a3d9faf54145e954e9 |
|
BLAKE2b-256 | 06223665c334b3470dfa3e954bf0318a74851f7dddace42001afeec0c6dc5014 |
Hashes for pyodps-0.10.6-cp35-cp35m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7039d72a8f5a23cdb9e98839a934d01d60a0b560d20dfa75429432acf7bec0ae |
|
MD5 | 8fdeff652a6b1f0223d5873f10e0c4a7 |
|
BLAKE2b-256 | 76c955c0229b857656082a5e1a283c6addbe8358c7b35b7a551857574d48ad2c |
Hashes for pyodps-0.10.6-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b3290cdf25bc231d4db33510b5e448fc7b2e07eabb4bd7e6ee2d528708cb209 |
|
MD5 | b2203908c13fef7dbc8ef6f97cacbdb9 |
|
BLAKE2b-256 | a3bb556f029c5b7a62b816e574d9e42b4b59dfffb6022cace4e1721f42a65bf1 |
Hashes for pyodps-0.10.6-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 | 065971ccfdfc248719ce36e651cb610fe1d089c1872d5d68ba81f951aedb4fab |
|
MD5 | c22baed8457adc34b8f6b9e5e9ce259f |
|
BLAKE2b-256 | c92f6232c143c128af732e25874af87df264b66fa9aac60ce727e6660673061f |
Hashes for pyodps-0.10.6-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eec975fd43ebb475bdefb4368fc1ef40ba790094e427134c76416909372cbba0 |
|
MD5 | 652999033fcb3f02b1e9fe7d974a1b7c |
|
BLAKE2b-256 | 398c66c65a69a10a07e6290fa9c0a773414647a50cc46a86fb0957205a67ba79 |
Hashes for pyodps-0.10.6-cp27-cp27m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b8e09497a2a1cff55d7886c0cd8a2c5e174fa49c5f7f20c7acd2abd986bbd74 |
|
MD5 | ded352a6279eedf9b09a62d8caf07124 |
|
BLAKE2b-256 | 10df1787ab238c7d7adc884a9548904c1fef8a1d4c92ffc6dd45a9870ea427fa |
Hashes for pyodps-0.10.6-cp27-cp27m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2148e22769376a6a91e631973c52078dd4db859f3b447885dc8afa54649a77e4 |
|
MD5 | 725556ff9757d9d07be780b2377cc50f |
|
BLAKE2b-256 | e14cc0e9eca1a10867626e2d64492ed747fb1f8f0a6da7ad99c82b9cc4c2a89d |
Hashes for pyodps-0.10.6-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 | df7c5130dc4c9cde2439973db84560172d3fade8653784f2bc0b343f0c9b63fe |
|
MD5 | 69945e4ec074ded4c3cebea9828af861 |
|
BLAKE2b-256 | 2f236c9167b6f6ca37fa3a04c298b754469707a25b0dc057a781917faa4aa08f |