Skip to content

Instantly share code, notes, and snippets.

@grst
Created February 14, 2018 21:08
Show Gist options
  • Save grst/31f4e0c0ff84b049cdb43537a7f88939 to your computer and use it in GitHub Desktop.
Save grst/31f4e0c0ff84b049cdb43537a7f88939 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"34.3 s ± 145 ms per loop (mean ± std. dev. of 3 runs, 1 loop each)\n"
]
}
],
"source": [
"%%timeit -n1 -r3\n",
"tab = pd.read_csv(\"./input_big.csv\")\n",
"tab[\"field7\"] = \"London\"\n",
"tab.to_csv(\"./output.csv\", index=False)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Initial version (from the top)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1min 23s ± 134 ms per loop (mean ± std. dev. of 3 runs, 1 loop each)\n"
]
}
],
"source": [
"%%timeit -n1 -r3\n",
"!./test.d input_big.csv field7 London output_d.csv"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Optimized version (from the bottom)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"!ldc ./optimized.d"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"29.7 s ± 203 ms per loop (mean ± std. dev. of 3 runs, 1 loop each)\n"
]
}
],
"source": [
"%%timeit -n1 -r3\n",
"!./optimized input_big.csv field7 London output_d.csv"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"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.6.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment