K2data内部的数据分析工具包
Project description
k2magic
K2Magic是K2Assets提供的数据分析开发包(以下简称SDK),用于简化Python里访问各类数据库的操作。
安装sdk
执行以下命令安装:
pip install k2magic
使用sdk
使用方法详见DataFrameDB
类的帮助文档,下面是一个快速示例:
>>> import pandas as pd
>>> from k2magic.dataframe_db import DataFrameDB
>>>
>>> db = DataFrameDB('postgresql+psycopg2://...')
>>> df = db.select('table1', condition='col1 > 1')
>>> df = db.select('table1', limit=3, order_by=['k_device DESC'])
>>> data = {'k_device': ['a', 'b', 'c'], 'col1': [1, 2, 3], 'col2': [4, 5, 6]}
>>> df = pd.DataFrame(data)
>>> db.delete('table1')
>>> db.insert('table1', df)
>>> db.update('table1', df, index_keys=['k_device'])
>>> db.upsert('table1', df, index_keys=['k_device'])
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
k2magic-0.1.7.tar.gz
(10.6 kB
view details)
Built Distribution
k2magic-0.1.7-py3-none-any.whl
(10.7 kB
view details)
File details
Details for the file k2magic-0.1.7.tar.gz
.
File metadata
- Download URL: k2magic-0.1.7.tar.gz
- Upload date:
- Size: 10.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c8309a6df486074c4cd6efc81d92b3371fcc6533f58686bd0336e6dcb53802c1 |
|
MD5 | f17f907b6664110d1bdaa38f56dcb360 |
|
BLAKE2b-256 | def3565288d85cb7a78c3f5c0c3987f2f1571976b8a57ac43f7befb4a4837e6e |
File details
Details for the file k2magic-0.1.7-py3-none-any.whl
.
File metadata
- Download URL: k2magic-0.1.7-py3-none-any.whl
- Upload date:
- Size: 10.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2cbcf25d24d53d98549592cf588374552623f2715953912be6579224e44fb423 |
|
MD5 | 9bdd0544a767839581f5fcc50c76f044 |
|
BLAKE2b-256 | 5b05ad67aeb61c37ccabbac0072788acb3b8ca8bd73856a23344e9ad0eec8720 |