熊猫时间序列数据的快速存储

PyStore的Python项目详细描述


pystore-熊猫时间序列数据的快速数据存储

Python versionPyPi versionPyPi statusTravis-CI build statusStar this repoFollow me on twitter

PyStore是一个简单的(但强大的) 熊猫数据帧的数据存储,虽然它可以存储任何熊猫对象, 它的设计考虑了存储timeseries数据

它建在PandasNumpyDask,和Parquet (通过Fastparquet) 为python开发人员提供易于使用的数据存储 每台客户机每秒查询数百万行。

==>;签出this Blog post 对于pystore背后的推理和哲学,以及一个带有代码示例的详细教程。

==>;以Jupyter笔记本格式跟随this PyStore tutorial

快速启动

安装pystore

使用pip安装

$ pip install PyStore

或使用以下命令进行升级:

$ pip install PyStore --upgrade --no-cache-dir

安装说明: 如果没有安装Snappy(压缩/解压缩库),则需要 你需要install it first

使用pystore

#!/usr/bin/env python# -*- coding: utf-8 -*-importpystoreimportquandl# Set storage path (optional, default is `~/pystore`)pystore.set_path("~/pystore")# List storespystore.list_stores()# Connect to datastore (create it if not exist)store=pystore.store('mydatastore')# List existing collectionsstore.list_collections()# Access a collection (create it if not exist)collection=store.collection('NASDAQ')# List items in collectioncollection.list_items()# Load some data from Quandlaapl=quandl.get("WIKI/AAPL",authtoken="your token here")# Store the first 100 rows of the data in the collection under "AAPL"collection.write('AAPL',aapl[:100],metadata={'source':'Quandl'})# Reading the item's dataitem=collection.item('AAPL')data=item.data# <-- Dask dataframe (see dask.pydata.org)metadata=item.metadatadf=item.to_pandas()# Append the rest of the rows to the "AAPL" itemcollection.append('AAPL',aapl[100:])# Reading the item's dataitem=collection.item('AAPL')data=item.datametadata=item.metadatadf=item.to_pandas()# --- Query functionality ---# Query avaialable symbols based on metadatacollection.list_items(some_key='some_value',other_key='other_value')# --- Snapshot functionality ---# Snapshot a collection# (Point-in-time named reference for all current symbols in a collection)collection.create_snapshot('snapshot_name')# List available snapshotscollection.list_snapshots()# Get a version of a symbol given a snapshot namecollection.item('AAPL',snapshot='snapshot_name')# Delete a collection snapshotcollection.delete_snapshot('snapshot_name')# ...# Delete the item from the current versioncollection.delete_item('AAPL')# Delete the collectionstore.delete_collection('NASDAQ')

概念

pystore提供了名空间的collections数据。 这些集合允许通过sourceuser或其他度量对数据进行bucketing (例如频率:一天结束;分钟酒吧等)。每个集合(或命名空间) 映射到包含每个项(例如符号)的分区parquet文件的目录。

一个很好的做法是创建看起来像这样的集合:

  • collection.eod
  • collection.one分钟

要求

  • python>;=3.5
  • 熊猫
  • 努比
  • 达斯克
  • 快拼花
  • Snappy(谷歌的压缩/解压库)
  • 多任务处理

pystore经过测试可以在类似于*nix的系统上工作,包括macos。

依赖关系:

pystore使用Snappy, 来自google的快速高效的压缩/解压库。 在安装pystore之前,您需要在系统上安装snapy。

*有关详细信息,请参见python-snappyGithub repo

*nix系统:

  • 公寓:sudo apt-get install libsnappy-dev
  • 转速:sudo yum install libsnappy-devel

macos:

首先,使用Homebrew

$ brew install snappy

然后,使用conda:

$ conda install python-snappy -c conda-forge

…或者,使用pip

$ CPPFLAGS="-I/usr/local/include -L/usr/local/lib" pip install python-snappy

windows:

windows用户应该签出Snappy for Windowsthis Stackoverflow post以获取有关安装snappy和python-snappy的帮助。

路线图

pystore目前支持本地文件系统。 我计划增加对amazon s3的支持(通过s3fs), 谷歌云存储(通过gcsfs) 以及未来的hadoop分布式文件系统(通过hdfs3)。

致谢

pystore的灵感来自Man AHLArctic使用 MongoDB用于存储,并允许版本控制和其他功能。 我强烈建议你去看看。

许可证

pystore是根据apache许可证(2.0版)授权的。其副本包含在license.txt中。


我对你在Pystore的经历很感兴趣。 请给我一张便条,上面有你的任何反馈。

欢迎投稿!

-ran唤醒

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
windows请帮助获取java。运行程序时发生lang.nullpointerexception   JPA标准中的错误:java。lang.IllegalArgumentException:此JPQLquery中没有名为“:inputMsgId_1_”的参数   java调度一个小程序,从ScheduledExecutorService开始   java点击AVD“创建设备”按钮抛出NullPointerException   缓存Java9WebStart会多次加载jar文件   使用java计算最小二乘   当代理关闭时,java kafka生产者不会抛出异常   我们什么时候以及为什么要在java中进行自定义序列化?   java使用GSON解析包含包含所需字符串的对象的对象数组   java如何使用BOBJ REST API实现分页?   java身份验证失败:用户的凭据已过期。CAS v4。2.   合并排序中的java无限循环?   java jackson xml将pojo子元素转换为字符串   tcp Java ObjectOutputStream重置错误   如何调用。bat文件,并使用java中的ProcessBuilder发送字符串   奇怪的Java数学结果   java如何在Android中禁用最近的活动按钮?   java刷下应用程序崩溃   使用Java收集所有VersionOne资产及其所有属性   Java打印:创建具有最小可接受边距的页面格式