Skip to content

Instantly share code, notes, and snippets.

@scari
Last active August 29, 2015 14:20
Show Gist options
  • Save scari/1173a9519d8b89000c08 to your computer and use it in GitHub Desktop.
Save scari/1173a9519d8b89000c08 to your computer and use it in GitHub Desktop.
pandas7754_resample_perf.ipynb
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"100 loops, best of 3: 10.4 ms per loop\n",
"100 loops, best of 3: 10.2 ms per loop\n"
]
}
],
"source": [
"# https://github.com/pydata/pandas/issues/7754\n",
"import pandas as pd\n",
"\n",
"intSeries = pd.Series(5, pd.date_range(start='2000-01-01', end='2000-01-05', freq='555000U'), dtype='int64')\n",
"timeSeries = intSeries.astype('datetime64[ns]')\n",
"\n",
"%timeit intSeries.resample('1S', how='last') # It took 464 func calls (455 primitive calls) in 0.013 secs without the fix\n",
"%timeit timeSeries.resample('1S', how='last') # It took 12787933 func calls (12442313 primitive calls) in 12.516 secs without the fix"
]
},
{
"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
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment