pd.isnull
與工程(東西都迭代器)e.g
>>> import pandas as pd
>>> import numpy as np
>>> pd.isnull(np.array([1, 2]))
array([False, False], dtype=bool)
>>> pd.isnull([1, 2])
array([False, False], dtype=bool)
而df.isnull
是綁定到你的數據框對象的成員函數不同類型的輸入。因此,只要首先創建DataFrame成本高昂,就可以使用pd.isnull
。
時序:
In [30]: %timeit pd.isnull([1,2])
The slowest run took 8.93 times longer than the fastest. This could mean that an intermediate result is being cached.
100000 loops, best of 3: 9.19 µs per loop
In [33]: %timeit pd.DataFrame([1,2]).isnull()
The slowest run took 6.42 times longer than the fastest. This could mean that an intermediate result is being cached.
1000 loops, best of 3: 202 µs per loop
相關:[?爲什麼numpy的有許多ndarray方法相應的功能(http://stackoverflow.com/questions/29120730/why-does-numpy-have -a-相應功能換許多-ndarray的方法) – ayhan