用于cloogy的python api客户端
cloog的Python项目详细描述
#cloogy的python客户端安装cloogy
在终端:`pip3 install cloogy`
或在python shell或笔记本中:
``python
import pip
pip.main(['install','cloogy'])
``````
``python
`import yaml
from cloogy import cloogyclient
``
获取您的凭据
>获取您的登录名和密码。
在本例中,我们将从一个yaml文件中加载它。
`` python
`` python
` `‘credencredencredencredencredentials=yaml.load(f)
` `
` ` ` `` python
` `` login=credencredencredencredencredencredencredencredencredencredencredencredencredenci‘password’]
`
` `
` `35分;2分。创建cloogyclient
如果您提供登录名和密码,将为您处理身份验证。
``python
client=cloogyclient(login=login,password=password)
````
3。列出你的单位
``` python
units=client.get懔units()
``````
``` python
``` units
````
4。通过id
`` python
`` python
`` python
`` python
`` python
`` python
` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` `
5.找出一些关于你的单元的信息,unit类是普通python dict的扩展,这意味着它的行为类似于普通dict,但是增加了一些额外的功能。列出登录时可用的所有标记
``python
client.get_tags()
```
7。列出一个单元的可用标记
``python
tags=unit.get_tags()
````
``python
``tags
``````
``python
``tag in tags]
````
``8。直接获取特定标签
``python
>tag.get_last_communication_date()
````
9.获取消耗量
`` python
结束)
```
``python
client.get消费(
granularity=hourly',可以是即时的、每小时的、每天的、每月的、每年的
start=start,
end=end,
tag s=[tag\u id],标签id的列表
instants\u type=none;如何聚合即时测量。可以是avg,max,min,stdev。默认值为avg.
)
````
10。获取数据帧的消耗量
对于一些简单的分析,包括获取熊猫数据帧数据的方法
=pd.timestamp('20180101')
end=pd.timestamp('20180417')
``````
``python
``client.get_consumptions_dataframe(granularity='monthly',start=start,end=end,tags=tag_id)
```
这样的平面表很好,但它可以包含多个tagid,我们也可以得到一个只供阅读的表:
阴谋!
%matplotlib inline
df.plot.bar()
````
在终端:`pip3 install cloogy`
或在python shell或笔记本中:
``python
import pip
pip.main(['install','cloogy'])
``````
``python
`import yaml
from cloogy import cloogyclient
``
获取您的凭据
>获取您的登录名和密码。
在本例中,我们将从一个yaml文件中加载它。
`` python
`` python
` `‘credencredencredencredencredentials=yaml.load(f)
` `
` ` ` `` python
` `` login=credencredencredencredencredencredencredencredencredencredencredencredencredenci‘password’]
`
` `
` `35分;2分。创建cloogyclient
如果您提供登录名和密码,将为您处理身份验证。
``python
client=cloogyclient(login=login,password=password)
````
3。列出你的单位
``` python
units=client.get懔units()
``````
``` python
``` units
````
4。通过id
`` python
`` python
`` python
`` python
`` python
`` python
` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` `
5.找出一些关于你的单元的信息,unit类是普通python dict的扩展,这意味着它的行为类似于普通dict,但是增加了一些额外的功能。列出登录时可用的所有标记
``python
client.get_tags()
```
7。列出一个单元的可用标记
``python
tags=unit.get_tags()
````
``python
``tags
``````
``python
``tag in tags]
````
``8。直接获取特定标签
``python
>tag.get_last_communication_date()
````
9.获取消耗量
`` python
结束)
```
``python
client.get消费(
granularity=hourly',可以是即时的、每小时的、每天的、每月的、每年的
start=start,
end=end,
tag s=[tag\u id],标签id的列表
instants\u type=none;如何聚合即时测量。可以是avg,max,min,stdev。默认值为avg.
)
````
10。获取数据帧的消耗量
对于一些简单的分析,包括获取熊猫数据帧数据的方法
=pd.timestamp('20180101')
end=pd.timestamp('20180417')
``````
``python
``client.get_consumptions_dataframe(granularity='monthly',start=start,end=end,tags=tag_id)
```
这样的平面表很好,但它可以包含多个tagid,我们也可以得到一个只供阅读的表:
阴谋!
%matplotlib inline
df.plot.bar()
````