An explanation of randint(2) < 1 in python, I cannot understand what the < 1 does
Question: In python, given **randint(2) < 1**, could someone please explain what the **<
1** means or does?

I am using IP[y]: Notebook

Please excuse the previous lack of information, this is the code

    
    
    %pylab inline
    from __future__ import division
    import pandas as pd
    c = randint(2 ,size=100) < 1
    s1 = pd.Series(c)
    s1.head()
    s1.value_counts()
    


Answer: That line produces a truth matrix.

The [`numpy.random.randint()`
function](http://docs.scipy.org/doc/numpy/reference/generated/numpy.random.randint.html),
with a `size` argument, produces a new `numpy.ndarray` object with `size`
elements randomly picked between 0 and 2 (_exclusive_), so in this case 100 0
or 1 values:

    
    
    >>> numpy.random.randint(2, size=100)
    array([0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1,
           0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
           1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1,
           0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0,
           1, 1, 1, 1, 1, 1, 1, 0])
    

The `< 1` then produces an array of boolean values (`True` or `False`):

    
    
    >>> numpy.random.randint(2, size=100) < 1
    array([False, False, False, False,  True, False,  True,  True,  True,
           False, False,  True,  True,  True, False, False,  True,  True,
            True, False, False,  True,  True,  True, False, False,  True,
           False, False, False, False, False,  True,  True, False,  True,
           False, False, False,  True, False,  True, False,  True, False,
           False,  True,  True,  True, False,  True,  True, False, False,
           False,  True,  True, False, False, False,  True, False,  True,
            True,  True, False, False, False,  True, False, False, False,
           False, False,  True,  True,  True,  True, False,  True, False,
            True,  True, False,  True, False,  True, False,  True, False,
           False,  True, False, False, False,  True,  True, False,  True, False], dtype=bool)
    

This array is then converted to a Pandas `Series` object.

