Skip to content

Instantly share code, notes, and snippets.

@ashander
Last active April 10, 2016 22:03
Show Gist options
  • Save ashander/c9e7b5448fd08feb73828695c2d0ad3d to your computer and use it in GitHub Desktop.
Save ashander/c9e7b5448fd08feb73828695c2d0ad3d to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# feather vs hdf5 (via pandas)\n",
"\n",
"on spinning HD, not SSD :-\\ "
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import feather\n",
"import pandas as pd\n",
"import numpy as np\n",
"arr = np.random.randn(80000000)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"(40000, 2000)"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"arr[::10] = np.nan\n",
"df = pd.DataFrame(arr.reshape(40000,2000)).copy()\n",
"df.shape"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1 loop, best of 3: 13.4 s per loop\n"
]
}
],
"source": [
"%%timeit\n",
"feather.write_dataframe(df, 'test.feather')"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false,
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1 loop, best of 3: 1.2 s per loop\n"
]
}
],
"source": [
"%%timeit\n",
"df = feather.read_dataframe('test.feather')"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1 loop, best of 3: 14.5 s per loop\n"
]
}
],
"source": [
"%%timeit\n",
"df.to_hdf('test.h5', 'table')"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1 loop, best of 3: 413 ms per loop\n"
]
}
],
"source": [
"%%timeit\n",
"df = pd.read_hdf('test.h5', 'table')\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.4.3"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
appnope==0.1.0
backports-abc==0.4
Cython==0.24
decorator==4.0.9
entrypoints==0.2
feather-format==0.1.2
gnureadline==6.3.3
ipykernel==4.3.1
ipython==4.1.2
ipython-genutils==0.1.0
ipywidgets==4.1.1
Jinja2==2.8
jsonschema==2.5.1
jupyter==1.0.0
jupyter-client==4.2.2
jupyter-console==4.1.1
jupyter-core==4.1.0
MarkupSafe==0.23
mistune==0.7.2
nbconvert==4.2.0
nbformat==4.0.1
notebook==4.1.0
numexpr==2.5.2
numpy==1.11.0
pandas==0.18.0
pexpect==4.0.1
pickleshare==0.7.2
ptyprocess==0.5.1
Pygments==2.1.3
python-dateutil==2.5.2
pytz==2016.3
pyzmq==15.2.0
qtconsole==4.2.1
simplegeneric==0.8.1
six==1.10.0
tables==3.2.2
terminado==0.6
tornado==4.3
traitlets==4.2.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment