Line magic function `%%time` not found

Viewed 26021

%%time

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

The output results as an error and says UsageError: Line magic function %%time not found. Suggest some approach.

2 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.

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

Related