Take the 2-minute tour ×

I generated a traffic flow Series like this using pandas package:

data = np.array(data)
index = date_range(time_start[0],time_end[0],freq='30S')
s = Series(data, index=index)

the sample s output is like this:

2013-07-02 10:04:30     13242.0
2013-07-02 10:05:00     12354.3    

Here the first column is the index and second column is the value. My task is to collect all moments that their values (second column) are missing.

What I thought is this way:

for i in s:
   if isnull(i):

but 'None' can't be used to reference the index...

Will this cause efficiency if both missing value and s are large? Is there a better idea?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted
In [1]: import pandas as pd

In [2]: s = pd.Series([1, 2, 3, np.NaN, np.NaN, 5, 6])

In [3]: s.isnull()
0    False
1    False
2    False
3     True
4     True
5    False
6    False
dtype: bool

In [4]: s[s.isnull()]
3   NaN
4   NaN
dtype: float64

In [5]: s.index[s.isnull()]
Out[5]: Int64Index([3, 4], dtype=int64)
share|improve this answer
Thanks, what if the missing value is represented as empty string such as '' or ' '? –  Jin Jul 3 '13 at 17:46
@Jin -- s.index[s==''] gives you the indices... some good tips for working with missing data –  root Jul 3 '13 at 17:51
add comment

Your Answer


