Python包,用于离线访问Vega数据集
项目描述
vega_datasets
一个Python包,用于离线访问vega数据集。
本包有几个目标
- 为Python提供对vega-datasets GitHub存储库 中提供的数据集的简单访问。
- 以Pandas数据框的形式返回结果。
- wherever dataset size and/or license constraints make it possible, bundle the dataset with the package so that datasets can be loaded in the absence of a web connection.
目前该软件包捆绑了六个数据集,并回退到使用HTTP请求来获取其他数据集。
安装
vega_datasets
与Python 3.5或更高版本兼容。使用以下命令进行安装:
$ pip install vega_datasets
使用
此库中的主要对象是 data
>>> from vega_datasets import data
它包含访问所有可用数据集的属性,如果本地可用,则本地访问。例如,以下是著名的鸢尾花数据集
>>> df = data.iris()
>>> df.head()
petalLength petalWidth sepalLength sepalWidth species
0 1.4 0.2 5.1 3.5 setosa
1 1.4 0.2 4.9 3.0 setosa
2 1.3 0.2 4.7 3.2 setosa
3 1.5 0.2 4.6 3.1 setosa
4 1.4 0.2 5.0 3.6 setosa
如果您对源数据感兴趣,可以访问任何可用数据集的URL
>>> data.iris.url
'https://cdn.jsdelivr.net.cn/npm/vega-datasets@v1.29.0/data/iris.json'
对于捆绑在软件包中的数据集,您还可以在磁盘上找到它们的位置
>>> data.iris.filepath
'/lib/python3.6/site-packages/vega_datasets/data/iris.json'
可用数据集
要列出所有可用数据集,请使用 list_datasets
>>> data.list_datasets()
['7zip', 'airports', 'anscombe', 'barley', 'birdstrikes', 'budget', 'budgets', 'burtin', 'cars', 'climate', 'co2-concentration', 'countries', 'crimea', 'disasters', 'driving', 'earthquakes', 'ffox', 'flare', 'flare-dependencies', 'flights-10k', 'flights-200k', 'flights-20k', 'flights-2k', 'flights-3m', 'flights-5k', 'flights-airport', 'gapminder', 'gapminder-health-income', 'gimp', 'github', 'graticule', 'income', 'iris', 'jobs', 'londonBoroughs', 'londonCentroids', 'londonTubeLines', 'lookup_groups', 'lookup_people', 'miserables', 'monarchs', 'movies', 'normal-2d', 'obesity', 'points', 'population', 'population_engineers_hurricanes', 'seattle-temps', 'seattle-weather', 'sf-temps', 'sp500', 'stocks', 'udistrict', 'unemployment', 'unemployment-across-industries', 'us-10m', 'us-employment', 'us-state-capitals', 'weather', 'weball26', 'wheat', 'world-110m', 'zipcodes']
要列出本地数据集(即捆绑在软件包中且无需网络连接即可使用的那些数据集),请使用 local_data
对象
>>> from vega_datasets import local_data
>>> local_data.list_datasets()
['airports', 'anscombe', 'barley', 'burtin', 'cars', 'crimea', 'driving', 'iowa-electricity', 'iris', 'seattle-temps', 'seattle-weather', 'sf-temps', 'stocks', 'us-employment', "wheat"]
我们计划在未来添加更多本地数据集,但需符合大小和许可约束。如果您想帮助此工作,请参阅 本地数据集问题
数据集信息
如果您想了解任何数据集的更多信息,请使用 description
属性
>>> data.iris.description
'This classic dataset contains lengths and widths of petals and sepals for 150 iris flowers, drawn from three species. It was introduced by R.A. Fisher in 1936 [1]_.'
此信息也是 data.iris
文档字符串的一部分。目前并非所有数据集都包含描述;我们希望在未来添加更多信息。
项目详情
下载文件
下载适用于您平台的应用程序。如果您不确定选择哪个,请了解更多关于 安装软件包 的信息。
源分发
vega_datasets-0.9.0.tar.gz (215.0 kB 查看哈希值)
构建分发
vega_datasets-0.9.0-py3-none-any.whl (210.8 kB 查看哈希值)
关闭
vega_datasets-0.9.0.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 9dbe9834208e8ec32ab44970df315de9102861e4cda13d8e143aab7a80d93fc0 |
|
MD5 | 5a17b42f507880037f9b7040b75d2e19 |
|
BLAKE2b-256 | 8fa0ce608d9a5b82fce2ebaa2311136b1e1d1dc2807f501bbdfa56bd174fff76 |
关闭
vega_datasets-0.9.0-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 3d7c63917be6ca9b154b565f4779a31fedce57b01b5b9d99d8a34a7608062a1d |
|
MD5 | f7752c8afa2243230549d7b8c8d2e6b0 |
|
BLAKE2b-256 | e69fca52771fe972e0dcc5167fedb609940e01516066938ff2ee28b273ae4f29 |