ó
šxŠ\c           @   sª  d  d l  Z  d  d l Z d  d l Z d  d l m Z d  d l j Z d  d l m Z m	 Z	 d  d l
 m Z d  d l m Z d  d l m Z m Z m Z m Z m Z m Z m Z m Z m Z d  d l m Z m Z m Z d  d l m Z m Z d  d l j  j! Z" d  d	 l# m$ Z$ m% Z% d
 „  Z& e' e( e( ƒ Z) d e* f d „  ƒ  YZ+ e+ ƒ  Z, d e- f d „  ƒ  YZ. d e f d „  ƒ  YZ/ d e/ f d „  ƒ  YZ0 d e/ f d „  ƒ  YZ1 d e1 f d „  ƒ  YZ2 d e1 f d „  ƒ  YZ3 d e/ f d „  ƒ  YZ4 d e4 f d „  ƒ  YZ5 d e4 f d „  ƒ  YZ6 e( d „ Z7 d  „  Z8 d! „  Z9 d" „  Z: d# „  Z; d$ „  Z< d% „  Z= d& „  Z> d' „  Z? d( „  Z@ d) „  ZA d* „  ZB d+ „  ZC d, „  ZD d- „  ZE eF d. „ ZG d S(/   iÿÿÿÿN(   t   _NDFrameIndexerBase(   t   ranget   zip(   t   AbstractMethodError(   t   Appender(	   t   ensure_platform_intt   is_floatt
   is_integert   is_integer_dtypet   is_iteratort   is_list_liket	   is_scalart   is_sequencet	   is_sparse(   t   ABCDataFramet   ABCPanelt	   ABCSeries(   t   _infer_fill_valuet   isna(   t   Indext
   MultiIndexc           C   s1   d t  f d t f d t f d t f d t f g S(   Nt   ixt   iloct   loct   att   iat(   t
   _IXIndexert   _iLocIndexert   _LocIndexert
   _AtIndexert   _iAtIndexer(    (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyt   get_indexers_list   s
    				t   _IndexSlicec           B   s   e  Z d  Z d „  Z RS(   s  
    Create an object to more easily perform multi-index slicing

    See Also
    --------
    MultiIndex.remove_unused_levels : New MultiIndex with no unused levels.

    Notes
    -----
    See :ref:`Defined Levels <advanced.shown_levels>`
    for further info on slicing a MultiIndex.

    Examples
    --------

    >>> midx = pd.MultiIndex.from_product([['A0','A1'], ['B0','B1','B2','B3']])
    >>> columns = ['foo', 'bar']
    >>> dfmi = pd.DataFrame(np.arange(16).reshape((len(midx), len(columns))),
                            index=midx, columns=columns)

    Using the default slice command:

    >>> dfmi.loc[(slice(None), slice('B0', 'B1')), :]
               foo  bar
        A0 B0    0    1
           B1    2    3
        A1 B0    8    9
           B1   10   11

    Using the IndexSlice class for a more intuitive command:

    >>> idx = pd.IndexSlice
    >>> dfmi.loc[idx[:, 'B0':'B1'], :]
               foo  bar
        A0 B0    0    1
           B1    2    3
        A1 B0    8    9
           B1   10   11
    c         C   s   | S(   N(    (   t   selft   arg(    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyt   __getitem__Q   s    (   t   __name__t
   __module__t   __doc__R#   (    (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyR    (   s   't   IndexingErrorc           B   s   e  Z RS(    (   R$   R%   (    (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyR'   X   s   t   _NDFrameIndexerc           B   sˆ  e  Z e Z e Z e Z e d  „ Z d „  Z d „  Z	 e d „ Z
 e d „ Z e e d „ Z d „  Z d „  Z d „  Z d	 „  Z d
 „  Z e d „ Z e d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z e d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z e d „ Z  d „  Z! d „  Z" d „  Z# e d „ Z$ e d „ Z% e d „ Z& e d „ Z' e e e d  „ Z( d! „  Z) e d" „ Z* RS(#   c         C   sF   |  j  |  j |  j ƒ } | d  k	 r9 |  j j | ƒ } n  | | _ | S(   N(   t	   __class__t   namet   objt   Nonet   _get_axis_numbert   axis(   R!   R.   t   new_self(    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyt   __call__a   s
    	c         C   s   t  d ƒ ‚ d  S(   Ns   ix is not iterable(   t   NotImplementedError(   R!   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyt   __iter__j   s    c            s°   t  | ƒ t k ru t ‡  f d †  | Dƒ ƒ } y& ˆ  j j | Œ  } t | ƒ rS | SWn t k
 rg n Xˆ  j | ƒ Sˆ  j p d } t j	 | ˆ  j ƒ } ˆ  j
 | d | ƒSd  S(   Nc         3   s$   |  ] } t  j | ˆ  j ƒ Vq d  S(   N(   t   comt   apply_if_callableR+   (   t   .0t   x(   R!   (    s3   lib/python2.7/site-packages/pandas/core/indexing.pys	   <genexpr>o   s   i    R.   (   t   typet   tupleR+   t
   _get_valueR   t	   Exceptiont   _getitem_tupleR.   R3   R4   t   _getitem_axis(   R!   t   keyt   valuesR.   (    (   R!   s3   lib/python2.7/site-packages/pandas/core/indexing.pyR#   m   s    c         C   sŠ   | d  k r |  j p d } n  |  j d k rC |  j j | d | ƒSt | t ƒ rt t | | t ƒ rt t d ƒ ‚ n  |  j j | d | ƒS(   Ni    i   R.   s    no slices here, handle elsewhere(	   R,   R.   t   ndimR+   t   _xst
   isinstanceR8   t   sliceR'   (   R!   t   labelR.   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyt
   _get_label€   s    "c         C   s.   | d  k r |  j } n  |  j j | d | ƒS(   NR.   (   R,   R.   R+   t   _ixs(   R!   R=   R.   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyt   _get_loc   s    c         C   s4   | d  k r |  j } n  |  j j | d | d | ƒS(   NR.   t   kind(   R,   R.   R+   t   _slice(   R!   R+   R.   RG   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyRH   ”   s    c         C   s.  |  j  d  k	 r" |  j | d t ƒS|  j j d ƒ } t | t ƒ rz |  j d k rz y | j	 | ƒ SWqz t
 k
 rv qz Xn  t | t ƒ r· y |  j | d t ƒSWq· t k
 r³ q· Xn  t | t ƒ rÙ |  j | d t ƒSy |  j | d t ƒSWn7 t k
 r)} d t | ƒ k r‚  n  t | ƒ ‚ n Xd  S(   Nt	   is_setteri    R   s	   cannot do(   R.   R,   t   _convert_tuplet   TrueR+   t	   _get_axisRA   R   R*   t   get_locR:   R8   R'   R   t   _convert_ranget   _convert_to_indexert	   TypeErrort   str(   R!   R=   R.   t   e(    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyt   _get_setitem_indexer™   s*    c            sf   t  | t ƒ r. t ‡  f d †  | Dƒ ƒ } n t j | ˆ  j ƒ } ˆ  j | ƒ } ˆ  j | | ƒ d  S(   Nc         3   s$   |  ] } t  j | ˆ  j ƒ Vq d  S(   N(   R3   R4   R+   (   R5   R6   (   R!   (    s3   lib/python2.7/site-packages/pandas/core/indexing.pys	   <genexpr>¹   s   (   RA   R8   R3   R4   R+   RS   t   _setitem_with_indexer(   R!   R=   t   valuet   indexer(    (   R!   s3   lib/python2.7/site-packages/pandas/core/indexing.pyt   __setitem__·   s    c         C   s   t  ƒ  ‚ d S(   sõ  
        Ensure that key is valid for current indexer.

        Parameters
        ----------
        key : scalar, slice or list-like
            The key requested

        axis : int
            Dimension on which the indexing is being made

        Raises
        ------
        TypeError
            If the key (or some element of it) has wrong type

        IndexError
            If the key (or some element of it) is out of bounds

        KeyError
            If the key was not found
        N(   R   (   R!   R=   R.   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyt   _validate_keyÀ   s    c         C   s…   x~ t  | ƒ D]p \ } } | |  j j k r: t d ƒ ‚ n  y |  j | | ƒ Wq t k
 r| t d j d |  j ƒ ƒ ‚ q Xq Wd S(   s0    check the key for valid keys across my indexer s   Too many indexerss5   Location based indexing can only have [{types}] typest   typesN(   t	   enumerateR+   R?   R'   RX   t
   ValueErrort   formatt   _valid_types(   R!   R=   t   it   k(    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyt   _has_valid_tupleÙ   s    c            s@   t  d „  |  j j Dƒ ƒ r< t  ‡  f d †  |  j j Dƒ ƒ St S(   Nc         s   s   |  ] } t  | t ƒ Vq d  S(   N(   RA   R   (   R5   t   ax(    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pys	   <genexpr>æ   s    c         3   s   |  ] } t  ˆ  | ƒ Vq d  S(   N(   t   is_nested_tuple(   R5   Ra   (   t   tup(    s3   lib/python2.7/site-packages/pandas/core/indexing.pys	   <genexpr>ç   s    (   t   anyR+   t   axest   False(   R!   Rc   (    (   Rc   s3   lib/python2.7/site-packages/pandas/core/indexing.pyt   _is_nested_tuple_indexerå   s     c         C   sû   g  } |  j  d  k	 r‹ |  j j |  j  ƒ } xÄ t |  j ƒ D]J } | | k rq | j |  j | d | d | ƒƒ q: | j t d  ƒ ƒ q: Wnf xc t	 | ƒ D]U \ } } | |  j j k rÅ t
 d ƒ ‚ n  |  j | d | d | ƒ} | j | ƒ q˜ Wt | ƒ S(   NR.   RI   s   Too many indexers(   R.   R,   R+   R-   R   R?   t   appendRO   RB   RZ   R'   R8   (   R!   R=   RI   t   keyidxR.   R^   R_   t   idx(    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyRJ   ê   s    c         C   s
   t  | ƒ S(   s    convert a range argument (   t   list(   R!   R=   RI   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyRN   ü   s    c         C   sM   | d  k r d } n  |  j j t | |  j d ƒ ƒ } | j | d |  j ƒS(   Ni    i   RG   (   R,   R+   RL   t   minR?   t   _convert_scalar_indexerR*   (   R!   R=   R.   Ra   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyRm      s    	"c         C   s8   |  j  j t | |  j d ƒ ƒ } | j | d |  j ƒS(   Ni   RG   (   R+   RL   Rl   R?   t   _convert_slice_indexerR*   (   R!   R=   R.   Ra   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyRn     s    "c         C   s   t  S(   N(   RK   (   R!   RV   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyt   _has_valid_setitem_indexer  s    c         C   s  t  | t ƒ r* t d j |  j ƒ ƒ ‚ nÔ t  | t ƒ sK |  j | ƒ } n  x° t |  j j	 | ƒ D]™ \ } } t  | t
 ƒ r qa t | ƒ rŽ qa t | ƒ rÍ | t | ƒ k rú t d j d |  j ƒ ƒ ‚ qú qa t  | t ƒ ra t d j d |  j ƒ ƒ ‚ qa qa Wt S(   sŒ    validate that an positional indexer cannot enlarge its target
        will raise if needed, does not modify the indexer externally
        s$   {0} cannot enlarge its target objects'   {name} cannot enlarge its target objectR*   (   RA   t   dictt
   IndexErrorR\   R*   R8   t   _tuplifyR   R+   Re   RB   t   is_list_like_indexerR   t   lenRK   (   R!   RV   Ra   R^   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyt%   _has_valid_positional_setitem_indexer  s$    	"c             sQ  ˆ j  | ƒ d d l m } ˆ j j ‰  ˆ j j } | r© ˆ j j j r© ˆ j j j \ } d | j k  r© t	 ˆ t
 ƒ r t ˆ j ƒ  ƒ n ˆ } | j | ƒ } q© n  t	 | t ƒ r4t | ƒ t ˆ j j ƒ k r4x[ t | ˆ j j ƒ D]A \ } } t	 | t ƒ rì t | ƒ pt j | ƒ rì t } Pqì qì Wn  t	 | t ƒ rg  }	 x­t | ƒ D]Ÿ\ } }
 t	 |
 t
 ƒ rèt |
 ƒ \ } } ˆ j d k re| ˆ j j k reg  t ˆ j j ƒ D]$ \ } } | | k r·t | ƒ ^ q·} t d „  | Dƒ ƒ r&t ˆ ƒ st d ƒ ‚ n  ˆ ˆ j | <ˆ j St ˆ ƒ ˆ j | <t | ˆ j j ƒ } ˆ j | ˆ ƒ ˆ j Sˆ j j | ƒ } | j  t | ƒ | ƒ ‰ ˆ j j! ˆ d | ƒj ˆ j _ ˆ j j" d t ƒ d  ˆ j _$ |	 j% ˆ j& | ƒ ƒ qV|	 j% |
 ƒ qVWt |	 ƒ } ntt | ƒ \ } } | r|ˆ j d k r_ˆ j j' } | j  t | ƒ | ƒ } | j( r—| j) | d g ƒ } | d k j ƒ  r—ˆ j | ˆ ƒ Sn  | ˆ g ƒ j* } t ˆ j j* ƒ ry t+ j, ˆ j j* | g ƒ } Wqt- k
 rˆ j j. t/ ƒ } t+ j, | | g ƒ } qXn  ˆ j j0 | d | d	 ˆ j j1 ƒj ˆ j _ ˆ j j" d t ƒ ˆ j Sˆ j d
 k rWt ˆ j j2 ƒ st d ƒ ‚ n  t	 ˆ | ƒ rÈˆ j! d ˆ j j2 d t ƒ ‰ | ˆ _1 nZ t ˆ ƒ rt ˆ ƒ t ˆ j j2 ƒ k rt d ƒ ‚ qn  | ˆ d ˆ j j2 d	 | ƒ‰ ˆ j j% ˆ ƒ j ˆ j _ ˆ j j" d t ƒ ˆ j Sˆ j d k r|ˆ j j3 | ˆ ƒ Sn  ˆ j j ˆ  ƒ } | r 
t	 | t ƒ sµˆ j4 | ƒ } n  t	 ˆ t5 ƒ rÙˆ j6 | ˆ ƒ ‰ n  | ˆ  } t | ƒ rû| g } n  | | ‰ t ˆ ƒ d k rdt	 ˆ j ˆ d j d t ƒ rdˆ d } ˆ j | } | j' } | ˆ   d }
 t |
 g ƒ | ˆ  d ‰ t7 ˆ d | ƒ ‰ t ˆ ƒ r¶t+ j8 ˆ ƒ r¶ˆ t ˆ ƒ k r¶t | |
 ƒ t ˆ ƒ k rìt d ƒ ‚ n  t9 ˆ d ˆ ƒ j: ƒ  ‰ | j; |
 ƒ }
 | j< ƒ  | j= ƒ  } | j j> d t |
 g ƒ d ˆ ƒ | _ | ˆ j | <d  SnR | ˆ   | ˆ  d ‰ ˆ  d k r°ˆ j j ˆ   d } t7 ˆ d | ƒ ‰ n d ‰ ‡ ‡ ‡ f d †  } ‡ ‡ ‡ ‡ ‡ f d †  } t ˆ ƒ rß	t9 ˆ d d ƒ d k rß	t	 ˆ t? ƒ r¥ˆ j d k r¥t | ƒ } t	 ˆ t ƒ } x–ˆ D]T } | ˆ k rˆ| | ˆ  <ˆ j6 t | ƒ ˆ | | ƒ } n	 t+ j@ } | | | ƒ qJWqý	tA ˆ d ƒ rÃˆ j d
 k sëtA ˆ d ƒ oât+ jB ˆ ƒ j d
 k rk	t+ jB ˆ d t/ ƒ‰ t ˆ ƒ ˆ jC d k r(	t d ƒ ‚ n  x± t ˆ ƒ D]/ \ } } | | ˆ d  d  … | f jD ƒ  ƒ q5	Wqý	| ƒ  rˆ	| ˆ d ˆ ƒ qý	t ˆ ƒ t ˆ ƒ k r¯	t d ƒ ‚ n  xK t ˆ ˆ ƒ D] \ } } | | | ƒ q¿	WqMxkˆ D] } | | ˆ ƒ qæ	WnMt	 | t ƒ r„
tE | Œ  } t | ƒ ˆ  k r„
t | ˆ  ƒ r„
tF ‡  f d †  t | ƒ Dƒ ƒ r„
| j( r„
ˆ ˆ j | | ˆ  <d  Sn  t	 ˆ t5 t
 f ƒ r´
ˆ j6 | | ˆ ƒ ƒ ‰ n$ t	 ˆ t? ƒ rØ
ˆ jG | ˆ ƒ ‰ n  t	 ˆ tH ƒ rü
ˆ jI | ˆ ƒ ‰ n  ˆ j jJ ƒ  ˆ j j< ƒ  ˆ j j j> d | d ˆ ƒ ˆ j _ ˆ j j" d t ƒ d  S(   Niÿÿÿÿ(   t   Seriesi   c         s   s   |  ] } | Vq d  S(   N(    (   R5   t   l(    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pys	   <genexpr>b  s    s5   cannot set a frame with no defined index and a scalarR.   t   cleart   indexR*   i   s*   cannot set a frame with no defined columnst   copys(   cannot set a row with mismatched columnsi   i    sW   cannot set using a multi-index selection indexer with a different length than the valueR>   RV   RU   c            s²   ˆ j  |  } ˆ  d k r# ˆ d n ˆ } t | t ƒ r] t ‡ f d †  | Dƒ ƒ r] | } nD | j ƒ  | j ƒ  } | j j d | d | ƒ | _ | j d t	 ƒ | ˆ j  |  <d  S(   Ni   i    c         3   s9   |  ]/ } t  j | ƒ p0 t  j | t ˆ  j ƒ ƒ Vq d  S(   N(   R3   t   is_null_slicet   is_full_sliceRt   R+   (   R5   Rj   (   R!   (    s3   lib/python2.7/site-packages/pandas/core/indexing.pys	   <genexpr>  s   RV   RU   Rx   (
   R+   RA   R8   t   allt   _consolidate_inplaceRz   t   _datat   setitemt   _maybe_update_cacherRK   (   t   itemt   vt   st   pi(   t   lplane_indexert   plane_indexerR!   (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyt   setter	  s    	
c             s‡   t  ˆ  ƒ d k s3 t j ˆ ƒ s3 t ˆ d ƒ r7 t Sˆ  d }  ˆ j |  j } t  ˆ ƒ } t  | ƒ | k rs t Sˆ | k rƒ t St S(   s.    return True if we have an equal len settable i   i    (   Rt   t   npt   iterableR   Rf   R+   Ry   RK   (   R‚   Ry   t
   values_len(   t   labelsR†   R‡   R!   RU   (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyt   can_do_equal_len!  s    #
R?   t   dtypes?   Must have equal len keys and value when setting with an ndarrays@   Must have equal len keys and value when setting with an iterablec         3   s0   |  ]& \ } } | ˆ  k r t  j | ƒ Vq d  S(   N(   R3   R{   (   R5   R^   Rj   (   t	   info_axis(    s3   lib/python2.7/site-packages/pandas/core/indexing.pys	   <genexpr>w  s   	(K   Ro   t   pandasRv   R+   t   _info_axis_numbert   _is_mixed_typeR   t   blocksR?   RA   Rp   Rk   R>   t   _can_hold_elementR8   Rt   Re   R   R   R   R3   R{   RK   RZ   t   convert_missing_indexerRd   Rs   R[   R   t"   convert_from_missing_indexer_tupleRT   RL   t   insertt   reindexR   R,   t   _is_copyRh   RM   Ry   t	   is_uniquet   get_indexert   _valuesR‰   t   concatenateRP   t   astypet   objectt   _constructorR*   t   columnsRW   Rr   R   t   _align_seriest   length_of_indexerRŠ   t   getattrt   ravelRn   R~   Rz   R€   R   t   nant   hasattrt   arrayt   shapet   tolistt   maybe_convert_ixR}   t   _align_frameR   t   _align_panelt%   _check_is_chained_assignment_possible(    R!   RV   RU   Rv   t   take_split_patht   blkt   valR^   Ra   t   nindexerRj   R=   t   _t   _it   _axt   len_non_info_axest   new_indexerRy   t   missingt	   new_indext
   new_valuest   as_objt   item_labelst   info_idxR‚   R+   t
   plane_axisRˆ   R   t   sub_indexert   multiindex_indexerRƒ   (    (   R   RŒ   R†   R‡   R!   RU   s3   lib/python2.7/site-packages/pandas/core/indexing.pyRT   +  sP   !-"!!		
		$		

!
	

$
	*		c         C   s  t  | t t j t t f ƒ r0 t | g ƒ } n  t  | t ƒ rÀd „  } t t | | ƒ ƒ } g  | D] } t j	 | ƒ ^ qd } t
 | ƒ } | d k } |  j j d k }	 |  j j d k }
 |  j } |	 rÞ | oØ | d } n# |
 r| oû | d pû | d } n  | |  j k ržt d „  | Dƒ ƒ rž| j | j d | d d t ƒj } t | ƒ d k rš| ršt | d ƒ } t j | | ƒ j | d ƒ j } n  | Sxlt | ƒ D]\ } } | j | } t | ƒ sßt  | t ƒ rj| rút j	 | ƒ rúq«n  | | } t | ƒ s"t | g ƒ } n t | ƒ } | j j | ƒ sMt | ƒ rZ| j j ƒ  S| j | ƒ j S| rÂ|	 rÂ|  j j d } | j j | ƒ s¥t | ƒ r²| j j ƒ  S| j | ƒ j S| r«g  } xd t |  j j | ƒ ƒ D]J \ } } t | | j @ƒ r| j | ƒ } qç| j | t | ƒ f ƒ qçW| j j ƒ  } xP | D]H \ } } d g t | ƒ d } | | | <t j | | ƒ j | ƒ } qKW|  j j d k rµ| j } n  | Sq«WnM t | ƒ r|  j j d ƒ } | j j | ƒ rý| j j ƒ  S| j | ƒ j St  d	 ƒ ‚ d
 S(   so  
        Parameters
        ----------
        indexer : tuple, slice, scalar
            The indexer used to get the locations that will be set to
            `ser`

        ser : pd.Series
            The values to assign to the locations specified by `indexer`

        multiindex_indexer : boolean, optional
            Defaults to False. Should be set to True if `indexer` was from
            a `pd.MultiIndex`, to avoid unnecessary broadcasting.


        Returns:
        --------
        `np.array` of `ser` broadcast to the appropriate shape for assignment
        to the locations selected by `indexer`

        c         S   s    t  |  t j ƒ r |  j ƒ  S|  S(   N(   RA   R‰   t   ndarrayR¥   (   R^   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyR¥   ¯  s    i   i   i   i    c         s   s   |  ] } t  | ƒ Vq d  S(   N(   R   (   R5   R³   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pys	   <genexpr>Ë  s    Rz   iÿÿÿÿs    Incompatible indexer with SeriesN(!   RA   RB   R‰   RÁ   Rk   R   R8   t   mapR3   R{   t   sumR+   R?   R}   R˜   Re   RK   Rœ   Rt   t   tilet   reshapet   TRZ   R   Rs   Ry   t   equalsRz   t   _get_plane_axesRh   R   RL   R[   (   R!   RV   t   serRÀ   R¥   Rj   t   alignerst   sum_alignerst   single_alignert   is_framet   is_panelR+   t   len_indexerR^   Ra   t   new_ixt	   broadcastt   nRŒ   R.   Rw   R©   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyR¢   “  sx    	#	'$
%
c         C   s  |  j  j d k } |  j  j d k } t | t ƒ rÅd	 \ } } g  } x© t | ƒ D]› \ } }	 |  j  j | }
 t |	 ƒ s‰ t |	 t ƒ rà t |	 t	 j
 ƒ rª |	 j ƒ  }	 n  | d  k rÃ |
 |	 } qí | d  k rÜ |
 |	 } qí PqR | j | ƒ qR W| rXt | ƒ d k r%| d d k r%| j } n  | d  k r=| j } n  | d  k rX| j } qXn  | d  k	 rñ| d  k	 rñ| j j | ƒ r¦| j j | ƒ r¦| j ƒ  j } n | j | d | ƒj } | Sn,t | t ƒ sàt | ƒ rx| rx|  j  j | }
 | j j |
 ƒ r| j ƒ  j } nZ t |
 t ƒ r_t | j t ƒ r_|
 j | j j k r_t d ƒ ‚ n  | j d |
 ƒ j } | St | ƒ rñ| rñ|  j  j d } |  j  j d } | j | j ƒ rÛ| j | j ƒ rÛ| j ƒ  j S| j | d | ƒj St d ƒ ‚ d  S(
   Ni   i   i   i    R¡   sA   cannot align on a multi-index with out specifying the join levelsRy   s#   Incompatible indexer with DataFrame(   NN(   R+   R?   RA   R8   R,   RZ   Re   R   RB   R‰   RÁ   R¥   Rh   Rt   RÆ   Ry   R¡   RÇ   Rz   Rœ   R˜   Rs   R   t   nlevelsRP   R   R[   (   R!   RV   t   dfRÍ   RÎ   Rj   t   colst	   sindexersR^   R   Ra   R±   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyR¬     s\    "$$c         C   s   t  d ƒ ‚ d  S(   Ns-   cannot set using an indexer with a Panel yet!(   R1   (   R!   RV   RÔ   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyR­   ^  s    c         C   sÏ   y |  j  | ƒ SWn t k
 r$ n X|  j | ƒ |  j | ƒ rN |  j | ƒ S|  j } xq t | ƒ D]c \ } } | |  j j k r‘ t d ƒ ‚ n  t j	 | ƒ r¦ qd n  t
 | |  j ƒ j | d | ƒ} qd W| S(   Ns   Too many indexersR.   (   t   _getitem_lowerdimR'   R`   t   _multi_take_opportunityt   _multi_takeR+   RZ   R?   R3   R{   R¤   R*   R<   (   R!   Rc   t   retvalR^   R=   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyR;   b  s    	%c         C   s8   t  d „  | Dƒ ƒ s t St d „  | Dƒ ƒ r4 t St S(   sŒ  
        Check whether there is the possibility to use ``_multi_take``.
        Currently the limit is that all axes being indexed must be indexed with
        list-likes.

        Parameters
        ----------
        tup : tuple
            Tuple of indexers, one per axis

        Returns
        -------
        boolean: Whether the current indexing can be passed through _multi_take
        c         s   s   |  ] } t  | ƒ Vq d  S(   N(   Rs   (   R5   R6   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pys	   <genexpr>‹  s    c         s   s   |  ] } t  j | ƒ Vq d  S(   N(   R3   t   is_bool_indexer(   R5   R6   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pys	   <genexpr>  s    (   R}   Rf   Rd   RK   (   R!   Rc   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyRØ   |  s
    c            sD   ˆ  j  } ‡  f d †  t | | j ƒ Dƒ } | j | d t d t ƒS(   s©  
        Create the indexers for the passed tuple of keys, and execute the take
        operation. This allows the take operation to be executed all at once -
        rather than once for each dimension - improving efficiency.

        Parameters
        ----------
        tup : tuple
            Tuple of indexers, one per axis

        Returns
        -------
        values: same type as the object being indexed
        c            s+   i  |  ]! \ } } ˆ  j  | | ƒ | “ q S(    (   t   _get_listlike_indexer(   R5   R=   R.   (   R!   (    s3   lib/python2.7/site-packages/pandas/core/indexing.pys
   <dictcomp>¥  s   	Rz   t
   allow_dups(   R+   R   t   _AXIS_ORDERSt   _reindex_with_indexersRK   (   R!   Rc   t   ot   d(    (   R!   s3   lib/python2.7/site-packages/pandas/core/indexing.pyRÙ   ”  s    	c         C   s   | S(   N(    (   R!   R=   R.   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyt   _convert_for_reindex©  s    c         C   s–   y |  j  | d |  j ƒSWnu t k
 r- ne t k
 r‘ } t | d t t f ƒ rd t d ƒ ‚ n  |  j j	 d ƒ } | j
 | ƒ s’ | ‚ q’ n Xd  S(   NR.   i    s   Handle elsewhere(   RD   R.   RP   R:   RA   RB   R   R'   R+   RL   t   is_lexsorted_for_tupleR,   (   R!   Rc   t   e1t   ax0(    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyt"   _handle_lowerdim_multi_index_axis0¬  s    c         C   s  |  j  d  k	 r7 |  j j |  j  ƒ } |  j | d | ƒS|  j | ƒ rS |  j | ƒ S|  j j d ƒ } t | t	 ƒ r¥ |  j
 d k r¥ |  j | ƒ } | d  k	 r¥ | Sn  t | ƒ |  j j k rÌ t d ƒ ‚ n  x/t | ƒ D]!\ } } t | ƒ s t | t ƒ rÙ |  j | d | ƒ} t | ƒ s%| S| j |  j k rW| |  t f | | d } n| | |  | | d } t | t ƒ rµ| d k rµt | ƒ d k rµ| \ }	 }
 |
 |	 f } n  t | ƒ d k rÓ| \ } n  t j | ƒ ræ| St | |  j
 ƒ | SqÙ Wt d ƒ ‚ d  S(   NR.   i    R   s#   Too many indexers. handle elsewherei   i   s   not applicable(   R.   R,   R+   R-   R<   Rg   t   _getitem_nested_tupleRL   RA   R   R*   Ræ   Rt   R?   R'   RZ   t   is_label_likeR8   Rs   t   _NSR   R3   R{   R¤   (   R!   Rc   R.   Rå   t   resultR^   R=   t   sectiont   new_keyt   at   b(    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyR×   À  s<     c         C   s<  t  | ƒ |  j k rJ |  j | ƒ } | d  k	 r4 | S|  j | d |  j ƒS|  j } d } xÜ t | ƒ D]Î \ } } t j	 | ƒ r‘ | d 7} qf n  | j } t
 | |  j ƒ j | d | ƒ} | d 7} t | ƒ sá t | d ƒ rå Pn  | j | k  rf | d k r'| d k r'| j d k r'| j } n  | d 8} qf qf W| S(   NR.   i    i   R?   i   i   (   Rt   R?   Ræ   R,   R<   R.   R+   RZ   R3   R{   R¤   R*   R   R§   RÆ   (   R!   Rc   Rê   R+   R.   R^   R=   t   current_ndim(    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyRç   ý  s*    	
	!
'c         C   s¸  | d  k r |  j p d } n  t | ƒ r9 t | ƒ } n  |  j | | ƒ |  j j | ƒ } t | t ƒ r} |  j	 | d | ƒSt
 | ƒ rè t | t ƒ o¤ t | t ƒ rè t | d ƒ rÕ | j d k rÕ t d ƒ ‚ n  |  j | d | ƒS| j | ƒ } t | ƒ r¡| d k rqt | t ƒ rqy |  j | d | ƒSWqqt t f k
 rm|  j j j d j ƒ  rn‚  qnqqXn  | j ƒ  r¡| j ƒ  r¡|  j | d | ƒSn  |  j | d | ƒSd  S(   Ni    R.   R?   i   s&   Cannot index with multidimensional key(   R,   R.   R	   Rk   RX   R+   RL   RA   RB   t   _get_slice_axisRs   R8   R   R§   R?   R[   t   _getitem_iterablet   _maybe_cast_indexerR   RD   t   KeyErrorRP   Ry   t   levelst   is_floatingRF   (   R!   R=   R.   RŒ   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyR<   -  s2    c   	      C   s  |  j  } | j | ƒ } | j | d |  j ƒ\ } } | d k	 r{ | d k j ƒ  r{ |  j | | | d | ƒ| | | f S| j r× t | ƒ s t | ƒ r² |  j	 | | ƒ } n  | j
 | ƒ } | j | ƒ d } n | j | ƒ \ } } } |  j | | | j | ƒ d | ƒ| | f S(   sE  
        Transform a list-like of keys into a new index and an indexer.

        Parameters
        ----------
        key : list-like
            Target labels
        axis: int
            Dimension on which the indexing is being made
        raise_missing: bool
            Whether to raise a KeyError if some labels are not found. Will be
            removed in the future, and then this method will always behave as
            if raise_missing=True.

        Raises
        ------
        KeyError
            If at least one key was requested but none was found, and
            raise_missing=True.

        Returns
        -------
        keyarr: Index
            New index (coinciding with 'key' if the axis is unique)
        values : array-like
            An indexer for the return object; -1 denotes keys not found
        RG   iÿÿÿÿt   raise_missingi    N(   R+   RL   t   _convert_listlike_indexerR*   R,   R}   t   _validate_read_indexerRš   Rt   Râ   t   get_indexer_forR˜   t   _reindex_non_uniqueR-   (	   R!   R=   R.   Rö   Rà   Ra   RV   t   keyarrR·   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyRÜ   T  s$    		c         C   sÎ   | d k r |  j p d } n  |  j | | ƒ |  j j | ƒ } t j | ƒ rƒ t | | ƒ } | j ƒ  \ } |  j j	 | d | ƒS|  j
 | | d t ƒ\ } } |  j j i | | g | 6d t d t ƒSd S(   s¯  
        Index current object with an an iterable key (which can be a boolean
        indexer, or a collection of keys).

        Parameters
        ----------
        key : iterable
            Target labels, or boolean indexer
        axis: int, default None
            Dimension on which the indexing is being made

        Raises
        ------
        KeyError
            If no key was found. Will change in the future to raise if not all
            keys were found.
        IndexingError
            If the boolean indexer is unalignable with the object being
            indexed.

        Returns
        -------
        scalar, DataFrame, or Series: indexed value(s),
        i    R.   Rö   Rz   RÝ   N(   R,   R.   RX   R+   RL   R3   RÛ   t   check_bool_indexert   nonzerot   _takeRÜ   Rf   Rß   RK   (   R!   R=   R.   RŒ   t   indsRû   RV   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyRñ   Œ  s    c   	      C   s  |  j  j | ƒ } t | ƒ d k r( d S| d k  j ƒ  } | r| t | ƒ k r t d j d | d |  j  j | ƒ ƒ ƒ ‚ n  |  j d k o’ | sÉ t t	 | ƒ t	 | ƒ ƒ } t d j | ƒ ƒ ‚ n  t
 j d ƒ } | j ƒ  pí | j ƒ  st j | t d	 d
 ƒqn  d S(   sR  
        Check that indexer can be used to return a result (e.g. at least one
        element was found, unless the list of keys was actually empty).

        Parameters
        ----------
        key : list-like
            Target labels (only used to show correct error message)
        indexer: array-like of booleans
            Indices corresponding to the key (with -1 indicating not found)
        axis: int
            Dimension on which the indexing is being made
        raise_missing: bool
            Whether to raise a KeyError if some labels are not found. Will be
            removed in the future, and then this method will always behave as
            if raise_missing=True.

        Raises
        ------
        KeyError
            If at least one key was requested but none was found, and
            raise_missing=True.
        i    Nu#   None of [{key}] are in the [{axis}]R=   R.   R   s   {} not in indexs,  
            Passing list-likes to .loc or [] with any missing label will raise
            KeyError in the future, you can use .reindex() as an alternative.

            See the documentation here:
            https://pandas.pydata.org/pandas-docs/stable/indexing.html#deprecate-loc-reindex-listliket
   stackleveli   (   R+   RL   Rt   RÃ   Ró   R\   t   _get_axis_nameR*   Rk   t   sett   textwrapt   dedentt   is_categoricalt   is_intervalt   warningst   warnt   FutureWarning(	   R!   R=   RV   R.   Rö   Ra   R¸   t	   not_foundt   _missing_key_warning(    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyRø   ¹  s"    	!		c   
      C   st  | d k r |  j p d } n  |  j j | ƒ } t | t ƒ rO |  j | | ƒ Sy |  j | | ƒ } Wn t k
 r | r‚ q‚ n X| j	 ƒ  } t	 | ƒ ož | } y | j
 | ƒ SWn‡ t k
 rt | t ƒ r<t | t ƒ r<| rt | ƒ | j k ri | d 6S‚  q<n- t k
 rn t k
 r;| s<‚  q<n X| rž| rš|  j d k rbi | d 6S| |  j j | k ršt | t ƒ ršt d ƒ ‚ qšn  | St | | ƒ rº| j | ƒ St | ƒ r*t j | ƒ r÷t | | ƒ } | j ƒ  \ } | Si | rt n | d 6}	 |  j | | |	  d SnF y | j
 | ƒ SWn2 t k
 rot | ƒ ri| rii | d 6S‚  n Xd S(   sÑ  
        Convert indexing key into something we can use to do actual fancy
        indexing on an ndarray

        Examples
        ix[:5] -> slice(0, 5)
        ix[[1,2,3]] -> [1,2,3]
        ix[['foo', 'bar', 'baz']] -> [i, j, k] (indices of foo, bar, baz)

        Going by Zen of Python?
        'In the face of ambiguity, refuse the temptation to guess.'
        raise AmbiguousIndexError with integer labels?
        - No, prefer label-based indexing
        i    R=   R   s2   cannot set by positional indexing with enlargementRö   i   N(   R,   R.   R+   RL   RA   RB   Rn   Rm   RP   R   RM   t   LookupErrorR8   R   Rt   RÓ   R[   R*   R©   Rb   t   get_locsRs   R3   RÛ   Rü   Rý   RK   RÜ   (
   R!   R+   R.   RI   Rö   RŒ   t   is_int_indext   is_int_positionalRÿ   t   kwargs(    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyRO   ÷  s`    	

c         C   s?   g  t  |  j ƒ D] } t d  d  ƒ ^ q } | | d <t | ƒ S(   Ni    (   R   R?   RB   R,   R8   (   R!   R   R³   Rc   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyRr   T  s    +
c         C   s—   |  j  } | d  k r' |  j p! d } n  t | ƒ sC | j d t ƒ S|  j | | ƒ } t | t ƒ r} |  j	 | d | d d ƒS|  j  j
 | d | ƒSd  S(   Ni    t   deepR.   RG   R   (   R+   R,   R.   t
   need_sliceRz   Rf   Rn   RA   RB   RH   Rþ   (   R!   t	   slice_objR.   R+   RV   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyRð   Y  s    	(+   R$   R%   R,   R]   Ró   t
   _exceptionR.   R0   R2   R#   RD   RF   RH   RS   RW   RX   R`   Rg   Rf   RJ   RN   Rm   Rn   Ro   Ru   RT   R¢   R¬   R­   R;   RØ   RÙ   Râ   Ræ   R×   Rç   R<   RÜ   Rñ   Rø   RO   Rr   Rð   (    (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyR(   \   sP   														ÿ i~	M						=	0'8->\	R   c           B   sM   e  Z d  Z e j d ƒ Z d „  Z e e j	 j ƒ d „  ƒ Z	 d d „ Z RS(   s£  A primarily label-location based indexer, with integer position
    fallback.

    Warning: Starting in 0.20.0, the .ix indexer is deprecated, in
    favor of the more strict .iloc and .loc indexers.

    ``.ix[]`` supports mixed integer and label based access. It is
    primarily label based, but will fall back to integer positional
    access unless the corresponding axis is of integer type.

    ``.ix`` is the most general indexer and will support any of the
    inputs in ``.loc`` and ``.iloc``. ``.ix`` also supports floating
    point label schemes. ``.ix`` is exceptionally useful when dealing
    with mixed positional and label based hierarchical indexes.

    However, when an axis is integer based, ONLY label based access
    and not positional access is supported. Thus, in such cases, it's
    usually better to be explicit and use ``.iloc`` or ``.loc``.

    See more at :ref:`Advanced Indexing <advanced>`.
    sõ   
        .ix is deprecated. Please use
        .loc for label based indexing or
        .iloc for positional indexing

        See the documentation here:
        http://pandas.pydata.org/pandas-docs/stable/indexing.html#ix-indexer-is-deprecatedc         C   s6   t  j |  j t d d ƒt t |  ƒ j | | ƒ d  S(   NR   i   (   R  R  t   _ix_deprecation_warningt   DeprecationWarningt   superR   t   __init__(   R!   R*   R+   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyR  ˆ  s    c         C   sJ   t  | t ƒ r t St j | ƒ r& t St | ƒ r6 t S|  j | | ƒ t S(   N(   RA   RB   RK   R3   RÛ   Rs   Rm   (   R!   R=   R.   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyRX     s    c         C   sÍ   | d k r |  j p d } n  |  j j | ƒ } t j | ƒ rV t | | ƒ } | | St | t ƒ rw | j	 | ƒ } n t j
 | ƒ } t | ƒ rÉ | j | ƒ } | j ƒ  sÉ t | ƒ } | j | ƒ Sn  | S(   s`  
        Transform a list of keys into a new array ready to be used as axis of
        the object we return (e.g. including NaNs).

        Parameters
        ----------
        key : list-like
            Target labels
        axis: int
            Where the indexing is being made

        Returns
        -------
        list-like of labels
        i    N(   R,   R.   R+   RL   R3   RÛ   Rü   RA   R   t   _convert_index_indexert   asarray_tuplesafeR   t   _convert_arr_indexerR   R   t   take(   R!   R=   R.   RŒ   Rû   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyRâ   ž  s    N(   R$   R%   R&   R  R  R  R  R   R(   RX   R,   Râ   (    (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyR   i  s   		t   _LocationIndexerc           B   sM   e  Z e Z d  „  Z d „  Z d „  Z d d „ Z d d „ Z	 d d „ Z
 RS(   c            s³   t  | ƒ t k rx t ‡  f d †  | Dƒ ƒ } y  ˆ  j | ƒ rM ˆ  j | ƒ SWn t t t f k
 rj n Xˆ  j | ƒ Sˆ  j p„ d } t	 j
 | ˆ  j ƒ } ˆ  j | d | ƒSd  S(   Nc         3   s$   |  ] } t  j | ˆ  j ƒ Vq d  S(   N(   R3   R4   R+   (   R5   R6   (   R!   (    s3   lib/python2.7/site-packages/pandas/core/indexing.pys	   <genexpr>Ï  s   i    R.   (   R7   R8   t   _is_scalar_accesst   _getitem_scalarRó   Rq   t   AttributeErrorR;   R.   R3   R4   R+   R<   (   R!   R=   R.   t   maybe_callable(    (   R!   s3   lib/python2.7/site-packages/pandas/core/indexing.pyR#   Í  s    c         C   s   t  ƒ  ‚ d  S(   N(   R1   (   R!   R=   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyR  Þ  s    c         C   s   t  ƒ  ‚ d  S(   N(   R1   (   R!   R=   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyR  á  s    c         C   s   t  ƒ  ‚ d  S(   N(   R1   (   R!   R=   R.   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyR<   ä  s    c         C   s‘   | d  k r |  j p d } n  |  j j | ƒ } t | | ƒ } | j ƒ  \ } y |  j j | d | ƒSWn" t k
 rŒ } |  j | ƒ ‚ n Xd  S(   Ni    R.   (	   R,   R.   R+   RL   Rü   Rý   Rþ   R:   R  (   R!   R=   R.   RŒ   Rÿ   t   detail(    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyt   _getbool_axisç  s    c         C   s»   | d k r |  j p d } n  |  j } t | ƒ sC | j d t ƒ S| j | ƒ } | j | j | j	 | j
 d |  j ƒ} t | t ƒ r¡ |  j | d | d d ƒS|  j j | d | ƒSd S(   s;    this is pretty simple as we just have to deal with labels i    R  RG   R.   R   N(   R,   R.   R+   R  Rz   Rf   RL   t   slice_indexert   startt   stopt   stepR*   RA   RB   RH   Rþ   (   R!   R  R.   R+   RŒ   RV   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyRð   ò  s    	N(   R$   R%   R:   R  R#   R  R  R,   R<   R#  Rð   (    (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyR  Ê  s   			R   c           B   s\   e  Z d  Z d Z e Z e e j j ƒ d „  ƒ Z d „  Z	 d „  Z
 d „  Z d d „ Z RS(   sS  
    Access a group of rows and columns by label(s) or a boolean array.

    ``.loc[]`` is primarily label based, but may also be used with a
    boolean array.

    Allowed inputs are:

    - A single label, e.g. ``5`` or ``'a'``, (note that ``5`` is
      interpreted as a *label* of the index, and **never** as an
      integer position along the index).
    - A list or array of labels, e.g. ``['a', 'b', 'c']``.
    - A slice object with labels, e.g. ``'a':'f'``.

      .. warning:: Note that contrary to usual python slices, **both** the
          start and the stop are included

    - A boolean array of the same length as the axis being sliced,
      e.g. ``[True, False, True]``.
    - A ``callable`` function with one argument (the calling Series, DataFrame
      or Panel) and that returns valid output for indexing (one of the above)

    See more at :ref:`Selection by Label <indexing.label>`

    Raises
    ------
    KeyError:
        when any items are not found

    See Also
    --------
    DataFrame.at : Access a single value for a row/column label pair.
    DataFrame.iloc : Access group of rows and columns by integer position(s).
    DataFrame.xs : Returns a cross-section (row(s) or column(s)) from the
        Series/DataFrame.
    Series.loc : Access group of values using labels.

    Examples
    --------
    **Getting values**

    >>> df = pd.DataFrame([[1, 2], [4, 5], [7, 8]],
    ...      index=['cobra', 'viper', 'sidewinder'],
    ...      columns=['max_speed', 'shield'])
    >>> df
                max_speed  shield
    cobra               1       2
    viper               4       5
    sidewinder          7       8

    Single label. Note this returns the row as a Series.

    >>> df.loc['viper']
    max_speed    4
    shield       5
    Name: viper, dtype: int64

    List of labels. Note using ``[[]]`` returns a DataFrame.

    >>> df.loc[['viper', 'sidewinder']]
                max_speed  shield
    viper               4       5
    sidewinder          7       8

    Single label for row and column

    >>> df.loc['cobra', 'shield']
    2

    Slice with labels for row and single label for column. As mentioned
    above, note that both the start and stop of the slice are included.

    >>> df.loc['cobra':'viper', 'max_speed']
    cobra    1
    viper    4
    Name: max_speed, dtype: int64

    Boolean list with the same length as the row axis

    >>> df.loc[[False, False, True]]
                max_speed  shield
    sidewinder          7       8

    Conditional that returns a boolean Series

    >>> df.loc[df['shield'] > 6]
                max_speed  shield
    sidewinder          7       8

    Conditional that returns a boolean Series with column labels specified

    >>> df.loc[df['shield'] > 6, ['max_speed']]
                max_speed
    sidewinder          7

    Callable that returns a boolean Series

    >>> df.loc[lambda df: df['shield'] == 8]
                max_speed  shield
    sidewinder          7       8

    **Setting values**

    Set value for all items matching the list of labels

    >>> df.loc[['viper', 'sidewinder'], ['shield']] = 50
    >>> df
                max_speed  shield
    cobra               1       2
    viper               4      50
    sidewinder          7      50

    Set value for an entire row

    >>> df.loc['cobra'] = 10
    >>> df
                max_speed  shield
    cobra              10      10
    viper               4      50
    sidewinder          7      50

    Set value for an entire column

    >>> df.loc[:, 'max_speed'] = 30
    >>> df
                max_speed  shield
    cobra              30      10
    viper              30      50
    sidewinder         30      50

    Set value for rows matching callable condition

    >>> df.loc[df['shield'] > 35] = 0
    >>> df
                max_speed  shield
    cobra              30      10
    viper               0       0
    sidewinder          0       0

    **Getting values on a DataFrame with an index that has integer labels**

    Another example using integers for the index

    >>> df = pd.DataFrame([[1, 2], [4, 5], [7, 8]],
    ...      index=[7, 8, 9], columns=['max_speed', 'shield'])
    >>> df
       max_speed  shield
    7          1       2
    8          4       5
    9          7       8

    Slice with integer labels for rows. As mentioned above, note that both
    the start and stop of the slice are included.

    >>> df.loc[7:9]
       max_speed  shield
    7          1       2
    8          4       5
    9          7       8

    **Getting values with a MultiIndex**

    A number of examples using a DataFrame with a MultiIndex

    >>> tuples = [
    ...    ('cobra', 'mark i'), ('cobra', 'mark ii'),
    ...    ('sidewinder', 'mark i'), ('sidewinder', 'mark ii'),
    ...    ('viper', 'mark ii'), ('viper', 'mark iii')
    ... ]
    >>> index = pd.MultiIndex.from_tuples(tuples)
    >>> values = [[12, 2], [0, 4], [10, 20],
    ...         [1, 4], [7, 1], [16, 36]]
    >>> df = pd.DataFrame(values, columns=['max_speed', 'shield'], index=index)
    >>> df
                         max_speed  shield
    cobra      mark i           12       2
               mark ii           0       4
    sidewinder mark i           10      20
               mark ii           1       4
    viper      mark ii           7       1
               mark iii         16      36

    Single label. Note this returns a DataFrame with a single index.

    >>> df.loc['cobra']
             max_speed  shield
    mark i          12       2
    mark ii          0       4

    Single index tuple. Note this returns a Series.

    >>> df.loc[('cobra', 'mark ii')]
    max_speed    0
    shield       4
    Name: (cobra, mark ii), dtype: int64

    Single label for row and column. Similar to passing in a tuple, this
    returns a Series.

    >>> df.loc['cobra', 'mark i']
    max_speed    12
    shield        2
    Name: (cobra, mark i), dtype: int64

    Single tuple. Note using ``[[]]`` returns a DataFrame.

    >>> df.loc[[('cobra', 'mark ii')]]
                   max_speed  shield
    cobra mark ii          0       4

    Single tuple for the index with a single label for the column

    >>> df.loc[('cobra', 'mark i'), 'shield']
    2

    Slice from index tuple to single label

    >>> df.loc[('cobra', 'mark i'):'viper']
                         max_speed  shield
    cobra      mark i           12       2
               mark ii           0       4
    sidewinder mark i           10      20
               mark ii           1       4
    viper      mark ii           7       1
               mark iii         16      36

    Slice from index tuple to index tuple

    >>> df.loc[('cobra', 'mark i'):('viper', 'mark ii')]
                        max_speed  shield
    cobra      mark i          12       2
               mark ii          0       4
    sidewinder mark i          10      20
               mark ii          1       4
    viper      mark ii          7       1
    sš   labels (MUST BE IN THE INDEX), slices of labels (BOTH endpoints included! Can be slices of integers if the index is integers), listlike of labels, booleanc         C   sI   t  | t ƒ r d  St j | ƒ r& d  St | ƒ sE |  j | | ƒ n  d  S(   N(   RA   RB   R3   RÛ   Rs   Rm   (   R!   R=   R.   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyRX   ø  s    c         C   s   t  | d ƒ s t St | ƒ |  j k r, t SxZ t | ƒ D]L \ } } t | ƒ sU t S|  j j | } t | t	 ƒ rx t S| j
 s9 t Sq9 Wt S(   Nt   __len__(   R§   Rf   Rt   R?   RZ   R   R+   Re   RA   R   Rš   RK   (   R!   R=   R^   R_   Ra   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyR  	  s    	c         C   s   |  j  j | Œ  } | S(   N(   R+   R9   (   R!   R=   R>   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyR  !  s    c         C   sô   t  | t ƒ rð t  | t j ƒ ra | j d j ra t | g t d ƒ g t	 | j ƒ d ƒ } n  t  | t ƒ rð g  } xe t
 | ƒ D]W \ } } t  | t j ƒ rÍ | j | j rÍ | j t | | d ƒ ƒ qƒ | j | ƒ qƒ Wt | ƒ } qð n  | S(   s_   Translate any partial string timestamp matches in key, returning the
        new key (GH 10331)i    i   N(   RA   R   t   compatt   string_typesRô   t   is_all_datesR8   RB   R,   Rt   RZ   Rh   (   R!   R=   RŒ   Rì   R^   t	   component(    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyt'   _get_partial_string_timestamp_match_key'  s    0c         C   sn  | d  k r |  j p d } n  t | ƒ r9 t | ƒ } n  |  j j | ƒ } |  j | | ƒ } t | t ƒ r |  j	 | | ƒ |  j
 | d | ƒSt j | ƒ r± |  j | d | ƒSt | ƒ rKt | t ƒ r˜t | t t j f ƒ r| j d k rt | ƒ } nK t | t ƒ r t d ƒ ‚ n- t | d ƒ rM| j d k rMt d ƒ ‚ n  t | t ƒ r˜t | ƒ d k r˜t | d t ƒ r˜t | g ƒ } q˜n  t | t ƒ o³t | t ƒ söt | d ƒ rã| j d k rãt d ƒ ‚ n  |  j | d | ƒSt | | ƒ rK| j | ƒ } t d  ƒ g |  j } | | | <|  j j t | ƒ Sn  |  j	 | | ƒ |  j | d | ƒS(   Ni    R.   i   s=   Indexing a MultiIndex with a DataFrame key is not implementedR?   sD   Indexing a MultiIndex with a multidimensional key is not implementeds&   Cannot index with multidimensional key(   R,   R.   R	   Rk   R+   RL   R-  RA   RB   RX   Rð   R3   RÛ   R#  Rs   R   R   R‰   RÁ   R?   R   R1   R§   R8   Rt   R[   Rñ   Rb   R  R   RD   (   R!   R=   R.   RŒ   t   locsRV   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyR<   ?  sB    '"
N(   R$   R%   R&   R]   Ró   R  R   R(   RX   R  R  R-  R,   R<   (    (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyR     s   ì			R   c           B   sƒ   e  Z d  Z d Z e Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d d „ Z d d	 „ Z d d
 „ Z d e d „ Z RS(   sÍ  
    Purely integer-location based indexing for selection by position.

    ``.iloc[]`` is primarily integer position based (from ``0`` to
    ``length-1`` of the axis), but may also be used with a boolean
    array.

    Allowed inputs are:

    - An integer, e.g. ``5``.
    - A list or array of integers, e.g. ``[4, 3, 0]``.
    - A slice object with ints, e.g. ``1:7``.
    - A boolean array.
    - A ``callable`` function with one argument (the calling Series, DataFrame
      or Panel) and that returns valid output for indexing (one of the above).
      This is useful in method chains, when you don't have a reference to the
      calling object, but would like to base your selection on some value.

    ``.iloc`` will raise ``IndexError`` if a requested indexer is
    out-of-bounds, except *slice* indexers which allow out-of-bounds
    indexing (this conforms with python/numpy *slice* semantics).

    See more at ref:`Selection by Position <indexing.integer>`.

    See Also
    --------
    DataFrame.iat : Fast integer location scalar accessor.
    DataFrame.loc : Purely label-location based indexer for selection by label.
    Series.iloc : Purely integer-location based indexing for
                   selection by position.

    Examples
    --------

    >>> mydict = [{'a': 1, 'b': 2, 'c': 3, 'd': 4},
    ...           {'a': 100, 'b': 200, 'c': 300, 'd': 400},
    ...           {'a': 1000, 'b': 2000, 'c': 3000, 'd': 4000 }]
    >>> df = pd.DataFrame(mydict)
    >>> df
          a     b     c     d
    0     1     2     3     4
    1   100   200   300   400
    2  1000  2000  3000  4000

    **Indexing just the rows**

    With a scalar integer.

    >>> type(df.iloc[0])
    <class 'pandas.core.series.Series'>
    >>> df.iloc[0]
    a    1
    b    2
    c    3
    d    4
    Name: 0, dtype: int64

    With a list of integers.

    >>> df.iloc[[0]]
       a  b  c  d
    0  1  2  3  4
    >>> type(df.iloc[[0]])
    <class 'pandas.core.frame.DataFrame'>

    >>> df.iloc[[0, 1]]
         a    b    c    d
    0    1    2    3    4
    1  100  200  300  400

    With a `slice` object.

    >>> df.iloc[:3]
          a     b     c     d
    0     1     2     3     4
    1   100   200   300   400
    2  1000  2000  3000  4000

    With a boolean mask the same length as the index.

    >>> df.iloc[[True, False, True]]
          a     b     c     d
    0     1     2     3     4
    2  1000  2000  3000  4000

    With a callable, useful in method chains. The `x` passed
    to the ``lambda`` is the DataFrame being sliced. This selects
    the rows whose index label even.

    >>> df.iloc[lambda x: x.index % 2 == 0]
          a     b     c     d
    0     1     2     3     4
    2  1000  2000  3000  4000

    **Indexing both axes**

    You can mix the indexer types for the index and columns. Use ``:`` to
    select the entire axis.

    With scalar integers.

    >>> df.iloc[0, 1]
    2

    With lists of integers.

    >>> df.iloc[[0, 2], [1, 3]]
          b     d
    0     2     4
    2  2000  4000

    With `slice` objects.

    >>> df.iloc[1:3, 0:3]
          a     b     c
    1   100   200   300
    2  1000  2000  3000

    With a boolean array whose length matches the columns.

    >>> df.iloc[:, [True, False, True, False]]
          a     c
    0     1     3
    1   100   300
    2  1000  3000

    With a callable function that expects the Series or DataFrame.

    >>> df.iloc[:, lambda df: [0, 2]]
          a     c
    0     1     3
    1   100   300
    2  1000  3000
    sl   integer, integer slice (START point is INCLUDED, END point is EXCLUDED), listlike of integers, boolean arrayc         C   sI  t  j | ƒ rd t | d ƒ r` t | j t ƒ r` | j j d k rQ t d ƒ ‚ n  t d ƒ ‚ n  d  St | t	 ƒ rw d  St
 | ƒ r– |  j | | ƒ n¯ t | t ƒ r´ t d ƒ ‚ n‘ t | ƒ r*t j | ƒ } t |  j j | ƒ ƒ } t | ƒ rE| j ƒ  | k s| j ƒ  | k  rEt d ƒ ‚ qEn t d j d |  j ƒ ƒ ‚ d  S(	   NRy   t   integersD   iLocation based boolean indexing on an integer type is not availablesB   iLocation based boolean indexing cannot use an indexable as a masks   Too many indexerss%   positional indexers are out-of-boundss+   Can only index by location with a [{types}]RY   (   R3   RÛ   R§   RA   Ry   R   t   inferred_typeR1   R[   RB   R   t   _validate_integerR8   R'   Rs   R‰   R¨   Rt   R+   RL   t   maxRl   Rq   R\   R]   (   R!   R=   R.   t   arrt   len_axis(    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyRX     s&    !1c         C   s   |  j  | ƒ d  S(   N(   Ru   (   R!   RV   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyRo   &  s    c         C   sz   t  | d ƒ s t St | ƒ |  j k r, t SxG t | ƒ D]9 \ } } t | ƒ sU t S|  j j | } | j s9 t Sq9 Wt	 S(   NR(  (
   R§   Rf   Rt   R?   RZ   R   R+   Re   Rš   RK   (   R!   R=   R^   R_   Ra   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyR  )  s    	c         C   s   |  j  j d t | Œ } | S(   Nt   takeable(   R+   R9   RK   (   R!   R=   R>   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyR  >  s    c         C   sD   t  |  j j | ƒ ƒ } | | k s1 | | k  r@ t d ƒ ‚ n  d S(   sk  
        Check that 'key' is a valid position in the desired axis.

        Parameters
        ----------
        key : int
            Requested position
        axis : int
            Desired axis

        Returns
        -------
        None

        Raises
        ------
        IndexError
            If 'key' is not a valid position in axis 'axis'
        s*   single positional indexer is out-of-boundsN(   Rt   R+   RL   Rq   (   R!   R=   R.   R4  (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyR1  D  s    c         C   sì   |  j  | ƒ y |  j | ƒ SWn t k
 r1 n X|  j } d } x¤ t | ƒ D]– \ } } | |  j j k r{ t d ƒ ‚ n  t j | ƒ rš | d 7} qN n  t | |  j	 ƒ j
 | d | ƒ} | j |  j k  rÚ | d 8} n  | d 7} qN W| S(   Ni    s   Too many indexersi   R.   (   R`   R×   R'   R+   RZ   R?   R3   R{   R¤   R*   R<   (   R!   Rc   RÚ   R.   R^   R=   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyR;   ]  s$    	
!c         C   s—   | d  k r |  j p d } n  |  j } t | ƒ sC | j d t ƒ S|  j | | ƒ } t | t ƒ r} |  j	 | d | d d ƒS|  j j
 | d | ƒSd  S(   Ni    R  R.   RG   R   (   R,   R.   R+   R  Rz   Rf   Rn   RA   RB   RH   Rþ   (   R!   R  R.   R+   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyRð   z  s    	c         C   s\   | d k r |  j p d } n  y |  j j | d | ƒSWn t k
 rW t d ƒ ‚ n Xd S(   sò   
        Return Series values by list or array of integers

        Parameters
        ----------
        key : list-like positional indexer
        axis : int (can only be zero)

        Returns
        -------
        Series object
        i    R.   s%   positional indexers are out-of-boundsN(   R,   R.   R+   Rþ   Rq   (   R!   R=   R.   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyt   _get_list_axisˆ  s    c         C   sô   | d  k r |  j p d } n  t | t ƒ r@ |  j | d | ƒSt | t ƒ ra t j | ƒ } n  t j	 | ƒ r“ |  j
 | | ƒ |  j | d | ƒSt | ƒ r² |  j | d | ƒSt | ƒ sÍ t d ƒ ‚ n  |  j | | ƒ |  j | d | ƒSd  S(   Ni    R.   s5   Cannot index by location index with a non-integer key(   R,   R.   RA   RB   Rð   Rk   R‰   t   asarrayR3   RÛ   RX   R#  Rs   R6  R   RP   R1  RF   (   R!   R=   R.   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyR<     s    c         C   s¤   | d k r |  j p d } n  t | t ƒ r= |  j | | ƒ St | ƒ rY |  j | | ƒ Sy |  j | | ƒ | SWn, t k
 rŸ t d j	 d |  j
 ƒ ƒ ‚ n Xd S(   s;    much simpler as we only have to deal with our valid types i    s+   Can only index by location with a [{types}]RY   N(   R,   R.   RA   RB   Rn   R   Rm   RX   R[   R\   R]   (   R!   R+   R.   RI   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyRO   º  s    N(   R$   R%   R&   R]   Rq   R  RX   Ro   R  R  R1  R;   R,   Rð   R6  R<   Rf   RO   (    (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyR   |  s   †						t   _ScalarAccessIndexerc           B   s,   e  Z d  Z e d „ Z d „  Z d „  Z RS(   s    access scalars quickly c         C   s
   t  | ƒ S(   N(   Rk   (   R!   R=   RI   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyt   _convert_keyÑ  s    c         C   sd   t  | t ƒ s< t | ƒ s- t | g ƒ } q< t d ƒ ‚ n  |  j | ƒ } |  j j d |  j | Œ S(   Ns)   Invalid call for scalar access (getting)!R5  (   RA   R8   Rs   R[   R9  R+   R9   t	   _takeable(   R!   R=   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyR#   Ô  s    c            sÐ   t  | t ƒ r. t ‡  f d †  | Dƒ ƒ } n t j | ˆ  j ƒ } t  | t ƒ sd ˆ  j | ƒ } n  t | ƒ ˆ  j j k r‹ t d ƒ ‚ n  t	 ˆ  j
 | d t ƒƒ } | j | ƒ ˆ  j j d ˆ  j | Œ d  S(   Nc         3   s$   |  ] } t  j | ˆ  j ƒ Vq d  S(   N(   R3   R4   R+   (   R5   R6   (   R!   (    s3   lib/python2.7/site-packages/pandas/core/indexing.pys	   <genexpr>â  s   s0   Not enough indexers for scalar access (setting)!RI   R5  (   RA   R8   R3   R4   R+   Rr   Rt   R?   R[   Rk   R9  RK   Rh   t
   _set_valueR:  (   R!   R=   RU   (    (   R!   s3   lib/python2.7/site-packages/pandas/core/indexing.pyRW   à  s    (   R$   R%   R&   Rf   R9  R#   RW   (    (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyR8  Î  s   	R   c           B   s    e  Z d  Z e Z e d „ Z RS(   sþ  
    Access a single value for a row/column label pair.

    Similar to ``loc``, in that both provide label-based lookups. Use
    ``at`` if you only need to get or set a single value in a DataFrame
    or Series.

    Raises
    ------
    KeyError
        When label does not exist in DataFrame

    See Also
    --------
    DataFrame.iat : Access a single value for a row/column pair by integer
        position.
    DataFrame.loc : Access a group of rows and columns by label(s).
    Series.at : Access a single value using a label.

    Examples
    --------
    >>> df = pd.DataFrame([[0, 2, 3], [0, 4, 1], [10, 20, 30]],
    ...                   index=[4, 5, 6], columns=['A', 'B', 'C'])
    >>> df
        A   B   C
    4   0   2   3
    5   0   4   1
    6  10  20  30

    Get value at specified row/column pair

    >>> df.at[4, 'B']
    2

    Set value at specified row/column pair

    >>> df.at[4, 'B'] = 10
    >>> df.at[4, 'B']
    10

    Get value within a Series

    >>> df.loc[5].at['B']
    4
    c         C   sŒ   | r t  | ƒ Sxu t |  j j | ƒ D]^ \ } } | j ƒ  r\ t | ƒ s„ t d ƒ ‚ q„ q& t | ƒ r& | j ƒ  r& t d ƒ ‚ q& q& W| S(   s[    require they keys to be the same type as the index (so we don't
        fallback)
        sD   At based indexing on an integer index can only have integer indexerssL   At based indexing on an non-integer index can only have non-integer indexers(   Rk   R   R+   Re   R   R[   t   holds_integer(   R!   R=   RI   Ra   R^   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyR9  #	  s    
"(   R$   R%   R&   Rf   R:  R9  (    (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyR   ò  s   -R   c           B   s)   e  Z d  Z e Z d „  Z e d „ Z RS(   s  
    Access a single value for a row/column pair by integer position.

    Similar to ``iloc``, in that both provide integer-based lookups. Use
    ``iat`` if you only need to get or set a single value in a DataFrame
    or Series.

    Raises
    ------
    IndexError
        When integer position is out of bounds

    See Also
    --------
    DataFrame.at : Access a single value for a row/column label pair.
    DataFrame.loc : Access a group of rows and columns by label(s).
    DataFrame.iloc : Access a group of rows and columns by integer position(s).

    Examples
    --------
    >>> df = pd.DataFrame([[0, 2, 3], [0, 4, 1], [10, 20, 30]],
    ...                   columns=['A', 'B', 'C'])
    >>> df
        A   B   C
    0   0   2   3
    1   0   4   1
    2  10  20  30

    Get value at specified row/column pair

    >>> df.iat[1, 2]
    1

    Set value at specified row/column pair

    >>> df.iat[1, 2] = 10
    >>> df.iat[1, 2]
    10

    Get value within a series

    >>> df.loc[0].iat[1]
    2
    c         C   s   |  j  | ƒ d  S(   N(   Ru   (   R!   RV   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyRo   i	  s    c         C   sE   x> t  |  j j | ƒ D]' \ } } t | ƒ s t d ƒ ‚ q q W| S(   s7    require integer args (and convert to label arguments) s1   iAt based indexing can only have integer indexers(   R   R+   Re   R   R[   (   R!   R=   RI   Rí   R^   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyR9  l	  s    "(   R$   R%   R&   RK   R:  Ro   Rf   R9  (    (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyR   9	  s   ,	c         C   s1  | d k	 ré t |  t ƒ ré t | ƒ } |  j } |  j } |  j } | d k rW d } n | d k  rp | | 7} n  | d k sˆ | | k r‘ | } n | d k  rª | | 7} n  | d k r¿ d } n | d k  rÕ | } n  | | | d | St |  t t t	 j
 t f ƒ rt |  ƒ St |  ƒ s!d St d ƒ ‚ d S(   sP   
    return the length of a single non-tuple indexer which could be a slice
    i    i   s%   cannot find the length of the indexerN(   R,   RA   RB   Rt   R%  R&  R'  R   R   R‰   RÁ   Rk   Rs   t   AssertionError(   RV   t   targett
   target_lenR%  R&  R'  (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyR£   u	  s.    						

c         C   s˜   |  j  } t | t ƒ r+ | j | d d ƒSt | t j ƒ r” |  j j j | ƒ rV d S| j
 r” y | j | ƒ SWq‘ t t t f k
 r d SXq” n  d S(   sQ   
    if we are index sliceable, then return my slicer, otherwise return None
    RG   t   getitemN(   Ry   RA   RB   Rn   R)  R*  R   t   itemst   containsR,   R+  t   _get_string_sliceRó   R[   R1   (   R+   R=   Rj   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyt   convert_to_index_sliceable’	  s    		c         C   s¿   | } t  | t ƒ rv | j j |  ƒ rv | j |  ƒ } t | j ƒ } | j ƒ  ra t d ƒ ‚ n  | j	 t
 ƒ j } nE t | ƒ r¦ | j ƒ  } t j | d t
 ƒ} n t j | d t
 ƒ} | S(   Nsr   Unalignable boolean Series provided as indexer (index of the boolean Series and of the indexed object do not matchRŽ   (   RA   R   Ry   RÇ   R˜   R   Rœ   Rd   R'   Rž   t   boolR   t   to_denseR‰   R7  (   Ra   R=   Rê   t   mask(    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyRü   «	  s    "c         C   sì   t  |  t j t f ƒ r‘ t | ƒ rè t |  ƒ t | ƒ k rè t  |  t j ƒ oy |  j t j k oy t |  |  ƒ t | ƒ k sŽ t d ƒ ‚ qŽ qè nW t  |  t	 ƒ rè t | ƒ rè t | ƒ rè t | ƒ t
 |  | ƒ k rå t d ƒ ‚ qå qè n  d S(   sW  
    Validate that value and indexer are the same length.

    An special-case is allowed for when the indexer is a boolean array
    and the number of true values equals the length of ``value``. In
    this case, no exception is raised.

    Parameters
    ----------
    indexer : sequence
        The key for the setitem
    value : array-like
        The value for the setitem
    values : array-like
        The values being set into

    Returns
    -------
    None

    Raises
    ------
    ValueError
        When the indexer is an ndarray or list and the lengths don't
        match.
    sK   cannot set using a list-like indexer with a different length than the valuesG   cannot set using a slice indexer with a different length than the valueN(   RA   R‰   RÁ   Rk   R
   Rt   RŽ   t   bool_R[   RB   R£   (   RV   RU   R>   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyt   check_setitem_lengthsÅ	  s    $c         C   sK   t  |  t ƒ rA |  d }  t  |  t ƒ r7 t d ƒ ‚ n  |  t f S|  t f S(   sƒ   
    reverse convert a missing indexer, which is a dict
    return the scalar indexer and a boolean indicating if we converted
    R=   s.   cannot use a single bool to index into setitem(   RA   Rp   RE  Ró   RK   Rf   (   RV   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyR•   ñ	  s    

c            s/   ‡  f d †  ‰ t  ‡ f d †  t |  ƒ Dƒ ƒ S(   sJ   
    create a filtered indexer that doesn't have any missing indexers
    c            s(   t  | t ƒ r$ ˆ  |  j | d ƒ S| S(   NR=   (   RA   Rp   RM   (   R´   t   _idx(   Re   (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyR›   
  s    $c         3   s$   |  ] \ } } ˆ  | | ƒ Vq d  S(   N(    (   R5   R´   RJ  (   R›   (    s3   lib/python2.7/site-packages/pandas/core/indexing.pys	   <genexpr>
  s    (   R8   RZ   (   RV   Re   (    (   Re   R›   s3   lib/python2.7/site-packages/pandas/core/indexing.pyR–   
  s    c         C   sµ   t  |  t ƒ rI t j |  ƒ }  t |  ƒ d k rI t j d d t j ƒSn  |  d k  } | j ƒ  r€ |  j ƒ  }  |  | c | 7<n  |  | k |  d k  B} | j ƒ  r± t	 d ƒ ‚ n  |  S(   sÓ  
    Attempt to convert indices into valid, positive indices.

    If we have negative indices, translate to positive here.
    If we have indices that are out-of-bounds, raise an IndexError.

    Parameters
    ----------
    indices : array-like
        The array of indices that we are to convert.
    n : int
        The number of elements in the array that we are indexing.

    Returns
    -------
    valid_indices : array-like
        An array-like of positive indices that correspond to the ones
        that were passed in initially to this function.

    Raises
    ------
    IndexError : one of the converted indices either exceeded the number
        of elements (specified by `n`) OR was still negative.
    i    RŽ   s   indices are out-of-bounds(
   RA   Rk   R‰   R¨   Rt   t   emptyt   intpRd   Rz   Rq   (   t   indicesRÒ   RG  (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyt   maybe_convert_indices
  s    c         C   ss   t  |  ƒ ro |  j ƒ  } | d k  rE d j | d ƒ } t | ƒ ‚ n  |  j ƒ  } | | k ro t d ƒ ‚ qo n  d S(   s  
    Perform bounds-checking for an indexer.

    -1 is allowed for indicating missing values.

    Parameters
    ----------
    indices : ndarray
    n : int
        length of the array being indexed

    Raises
    ------
    ValueError

    Examples
    --------
    >>> validate_indices([1, 2], 3)
    # OK
    >>> validate_indices([1, -2], 3)
    ValueError
    >>> validate_indices([1, 2, 3], 3)
    IndexError
    >>> validate_indices([-1, -1], 0)
    # OK
    >>> validate_indices([0, 1], 0)
    IndexError
    iÿÿÿÿs5   'indices' contains values less than allowed ({} < {})s   indices are out-of-boundsN(   Rt   Rl   R\   R[   R2  Rq   (   RM  RÒ   t   min_idxt   msgt   max_idx(    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyt   validate_indices;
  s    c          G   sY   t  } x5 |  D]- } t | t j t t t f ƒ s t } q q W| rQ t j |  Œ  S|  Sd S(   s2   
    We likely want to take the cross-product
    N(	   RK   RA   R‰   RÁ   Rk   R   R   Rf   t   ix_(   t   argst   ixifyR"   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyR«   d
  s    c         C   s\   t  |  t ƒ s t SxB t |  ƒ D]4 \ } } t | ƒ sG t  | t ƒ r  t  | t ƒ Sq  Wt S(   N(   RA   R8   Rf   RZ   R
   RB   R   (   Rc   RŒ   R^   R_   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyRb   t
  s    c         C   s,   t  |  ƒ o+ t |  t ƒ o* t |  ƒ t k	 S(   N(   R
   RA   R8   R7   (   R=   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyRs   
  s    c         C   s   t  |  t ƒ o t |  ƒ S(   N(   RA   RB   Rs   (   R=   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyRè   ‡
  s    c         C   s:   |  j  d  k	 p9 |  j d  k	 p9 |  j d  k	 o9 |  j d k S(   Ni   (   R%  R,   R&  R'  (   R+   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyR  Œ
  s    c         C   s|   |  } t  | t ƒ rQ x` | D]. } y |  j d ƒ }  Wq t k
 rI | SXq Wn' y |  j d ƒ }  Wn t k
 rw n X|  S(   Ni    (   RA   R8   t	   droplevelR[   (   Ry   R=   t   original_indexR³   (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyt   maybe_droplevels‘
  s    c         C   sÇ   t  t t j ƒ t t j t t g ƒ } t |  | ƒ rP t	 d d … |  f }  n  d „  } t
 |  ƒ s t |  t ƒ sƒ |  g g }  q½ |  g }  n. g  |  D]! } | | ƒ r® | n | g ^ q– }  t  |  ƒ S(   s·   
    Ensurse that a slice doesn't reduce to a Series or Scalar.

    Any user-paseed `subset` should have this called on it
    to make sure we're always working with DataFrames.
    Nc         S   s)   t  |  t ƒ s t |  ƒ o( t  |  t ƒ S(   N(   RA   RB   R
   R8   (   t   part(    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyt   pred²
  s    (   R8   Rk   R)  R*  R   R‰   RÁ   R   RA   t
   IndexSliceR
   RB   (   t   slice_t   kindsRZ  RY  (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyt   _non_reducing_slice¤
  s    		.c         C   sZ   | d k rV t j g } | r. | j t ƒ n  t d d … |  j d | ƒ j f } n  | S(   s†   
    want nice defaults for background_gradient that don't break
    with non-numeric data. But if slice_ is passed go with that.
    Nt   include(   R,   R‰   t   numberRh   RE  R[  t   select_dtypesR¡   (   RÔ   R\  t   include_boolt   dtypes(    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyt   _maybe_numeric_sliceÄ
  s    ((H   R  R  t   numpyR‰   t   pandas._libs.indexingR    t   pandas.compatR)  R   R   t   pandas.errorsR   t   pandas.util._decoratorsR   t   pandas.core.dtypes.commonR   R   R   R   R	   R
   R   R   R   t   pandas.core.dtypes.genericR   R   R   t   pandas.core.dtypes.missingR   R   t   pandas.core.commont   coret   commonR3   t   pandas.core.indexR   R   R   RB   R,   Ré   RŸ   R    R[  R:   R'   R(   R   R  R   R   R8  R   R   R£   RD  Rü   RI  R•   R–   RN  RR  R«   Rb   Rs   Rè   R  RX  R^  Rf   Rd  (    (    (    s3   lib/python2.7/site-packages/pandas/core/indexing.pyt   <module>   s`   @	-	ÿ ÿ ÿ ÿ ÿ a;ÿ xÿ S$G<			,			,	)							 