Nabih Ibrahim Bawazir
Nabih Ibrahim Bawazir

Reputation: 641

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 ?

Upvotes: 6

Views: 8654

Answers (1)

Matt
Matt

Reputation: 27843

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.

Upvotes: 22

Related Questions