#!/usr/bin/env python # coding: utf-8 # ![renumber-gif](http://i.imgur.com/ec6OXNR.gif) # In[1]: get_ipython().run_cell_magic('javascript', '', '\n$("#renumber-button").parent().remove();\n\nfunction renumber() {\n // renumber cells in order, so it doesn\'t look like you made any mistakes\n var i=1;\n IPython.notebook.get_cells().map(function (cell) {\n if (cell.cell_type == \'code\') {\n // set the input prompt\n cell.set_input_prompt(i);\n // set the output prompt (in two places)\n cell.output_area.outputs.map(function (output) {\n if (output.output_type == \'execute_result\') {\n output.execution_count = i;\n cell.element.find(".output_prompt").text(\'Out[\' + i + \']:\');\n }\n });\n i += 1;\n }\n });\n}\n\nIPython.toolbar.add_buttons_group([{\n \'label\' : \'Renumber\',\n \'icon\' : \'fa-list-ol\',\n \'callback\': renumber,\n \'id\' : \'renumber-button\'\n}]);\n') # In[2]: time.time() - start # In[3]: time.time() - start # In[4]: import time start = time.time() # In[5]: len(In)