Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why %time output is Wall time: 0 ns in Jupyter Notebook with IPython?

I try to measure query speed in my jupyter notbook

%time
a10= pd.read_sql('SELECT t.id, t.order_id FROM transactions.t', con=db_connection)

Whatever my query is the output always

Wall time: 0 ns

I assume %time is not related with previous cell, this cell requires more than 10s to execute, why Wall time: 0 ns ?

like image 469
Nabih Ibrahim Bawazir Avatar asked Sep 14 '17 09:09

Nabih Ibrahim Bawazir


1 Answers

Have a look at the introduction to IPython's magics; this is a IPython feature, not a Jupyter one.

There is a significant difference between a magic with One leading percent sign and a magic with Two leading percent signs. The first one applies only to the rest of the line it is on – in your case literally nothing —while the latter applies to the rest of the cell.

So you likely want to add a percent in front of your code.

You also most likely want to have a look at %timeit/%%timeit which differs from %time.

like image 138
Matt Avatar answered Oct 27 '22 00:10

Matt