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

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第三方库


热门话题
为@Nonnull注释参数编写java单元测试   对于JAVA,如何从它自己的类调用插入排序来将数组分类到一个单独的类中?   Java中嵌套SQL查询的字符串解析   java在所有带有特定注释的方法上调用带注释的方面   在Java中将base64转换为PDF   无法在Android上强制转换java getApplicationContext()   雅加达ee Java ee:如何获取我的应用程序的URL?   IntelliJ:如何导入的文件夹。java文件作为库?   多线程Java(FX)在播放一种声音的同时,播放另一种声音   网络爬虫我需要将proto3版本中protobuf生成的java代码添加到nutch 1.7中   使用JAXRS注释资源的java Restlet客户端   java如何查找给定月份的日期范围   java Minecraft Bukkit插件:我的小游戏传送机不工作   Java Excel搜索和数组列表工作不正常