Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Line magic function `%%time` not found

Running this python script

%%time
train_data = dt.fread('../input/prediction/train.csv').to_pandas()

The provided output returns this error:

UsageError: Line magic function `%%time` not found. Suggest some approach.
like image 505
Chandrachud Pati Avatar asked Dec 03 '20 10:12

Chandrachud Pati


3 Answers

%%time is a 'cell magic' and has to be the first thing in the IPython (Jupyter) cell. I can reproduce this error if for example I have a comment first. When %%time is not the first thing in the cell, IPython tries to interpret it as a 'line magic' hence the error you see.

I took a quick look in the documentation and it's not made explicitly clear there as far as I can see.

like image 173
Simon Judd Avatar answered Oct 07 '22 19:10

Simon Judd


%%time was the first thing in the cell and after going through the documentation i found %%time is now updated with %time

like image 28
Abdullah Avatar answered Sep 20 '22 11:09

Abdullah


You have to use %%time at top line of the cell in a notebook. Else it would throw the error.

like image 1
Antony Vibin Avatar answered Oct 07 '22 18:10

Antony Vibin