
x\c        	   @   sD  d  Z  d d l Z d d l Z d d l Z d d l j j Z d d l j	 Z	 d d l m
 Z
 m Z m Z m Z m Z d d l m Z d d l m Z d d l m Z m Z 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) d d l* m+ Z+ m, Z- d d l. m/ Z/ d d l0 j1 j2 Z2 e3   Z4 e3 d d d d d d d d  Z5 d e6 f d     YZ7 d e7 e/ f d     YZ8 d e6 f d     YZ9 d e: f d     YZ; d e; f d     YZ< d e; f d     YZ= d e6 f d      YZ> d e6 f d!     YZ? d S("   s.   
Base and utility classes for pandas objects.
iN(   t   PYPYt   OrderedDictt   builtinst   mapt   range(   t   function(   t   AbstractMethodError(   t   Appendert   Substitutiont   cache_readonly(   t   validate_bool_kwarg(	   t   is_datetime64_ns_dtypet   is_datetime64tz_dtypet   is_datetimeliket   is_extension_array_dtypet   is_extension_typet   is_list_liket   is_object_dtypet	   is_scalart   is_timedelta64_ns_dtype(   t   ABCDataFramet   ABCIndexClasst	   ABCSeries(   t   isna(   t
   algorithmst   common(   t   DirNamesMixint   klasst   IndexOpsMixint   inplacet    t   uniquet
   duplicatedt   StringMixinc           B   s2   e  Z d  Z d   Z d   Z d   Z d   Z RS(   s   implements string methods so long as object defines a `__unicode__`
    method.

    Handles Python2/3 compatibility transparently.
    c         C   s   t  |    d  S(   N(   R   (   t   self(    (    s/   lib/python2.7/site-packages/pandas/core/base.pyt   __unicode__-   s    c         C   s   t  j r |  j   S|  j   S(   s   
        Return a string representation for a particular Object

        Invoked by str(df) in both py2/py3.
        Yields Bytestring in Py2, Unicode String in py3.
        (   t   compatt   PY3R#   t	   __bytes__(   R"   (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyt   __str__0   s    	
c         C   s2   d d l  m } | d  } |  j   j | d  S(   s   
        Return a string representation for a particular object.

        Invoked by bytes(obj) in py3 only.
        Yields a bytestring in both py2/py3.
        i(   t
   get_options   display.encodingt   replace(   t   pandas.core.configR(   R#   t   encode(   R"   R(   t   encoding(    (    s/   lib/python2.7/site-packages/pandas/core/base.pyR&   <   s    c         C   s
   t  |   S(   s   
        Return a string representation for a particular object.

        Yields Bytestring in Py2, Unicode String in py3.
        (   t   str(   R"   (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyt   __repr__H   s    (   t   __name__t
   __module__t   __doc__R#   R'   R&   R.   (    (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyR!   !   s
   			t   PandasObjectc           B   s;   e  Z d  Z e d    Z d   Z d d  Z d   Z RS(   s$   baseclass for various pandas objectsc         C   s   |  j  S(   s7   class constructor (for this class it's just `__class__`(   t	   __class__(   R"   (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyt   _constructorU   s    c         C   s   t  j |   S(   s   
        Return a string representation for a particular object.

        Invoked by unicode(obj) in py2 only. Yields a Unicode String in both
        py2/py3.
        (   t   objectR.   (   R"   (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyR#   Z   s    c         C   sO   t  |  d d  d k r d S| d k r8 |  j j   n |  j j | d  d S(   sV   
        Reset cached properties. If ``key`` is passed, only clears that key.
        t   _cacheN(   t   getattrt   NoneR6   t   cleart   pop(   R"   t   key(    (    s/   lib/python2.7/site-packages/pandas/core/base.pyt   _reset_cached   s
    c         C   sY   t  |  d  rF |  j d t  } t |  s< | j   } n  t |  St t |   j   S(   sx   
        Generates the total memory usage for an object that returns
        either a value or Series of values
        t   memory_usaget   deep(	   t   hasattrR=   t   TrueR   t   sumt   intt   superR2   t
   __sizeof__(   R"   t   mem(    (    s/   lib/python2.7/site-packages/pandas/core/base.pyRD   o   s    
N(	   R/   R0   R1   t   propertyR4   R#   R8   R<   RD   (    (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyR2   Q   s
   	
t   NoNewAttributesMixinc           B   s    e  Z d  Z d   Z d   Z RS(   s~  Mixin which prevents adding new attributes.

    Prevents additional attributes via xxx.attribute = "something" after a
    call to `self.__freeze()`. Mainly used to prevent the user from using
    wrong attributes on a accessor (`Series.cat/.str/.dt`).

    If you really want to add a new attribute at a later time, you need to use
    `object.__setattr__(self, key, value)`.
    c         C   s   t  j |  d t  d S(   s&   Prevents setting additional attributest   __frozenN(   R5   t   __setattr__R@   (   R"   (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyt   _freeze   s    c         C   s~   t  |  d t  rg | d k pH | t |   j k pH t  |  | d   d  k	 rg t d j d |    n  t j |  | |  d  S(   NRH   R6   s(   You cannot add any new attribute '{key}'R;   (	   R7   t   Falset   typet   __dict__R8   t   AttributeErrort   formatR5   RI   (   R"   R;   t   value(    (    s/   lib/python2.7/site-packages/pandas/core/base.pyRI      s    (   R/   R0   R1   RJ   RI   (    (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyRG      s   		t   GroupByErrorc           B   s   e  Z RS(    (   R/   R0   (    (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyRQ      s   t	   DataErrorc           B   s   e  Z RS(    (   R/   R0   (    (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyRR      s   t   SpecificationErrorc           B   s   e  Z RS(    (   R/   R0   (    (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyRS      s   t   SelectionMixinc           B   sH  e  Z d  Z d Z d d g Z e e  Z e e	 j
 e j
 f e	 j e j f e	 j e j f f  Z e e	 j
 d f e	 j d f e	 j d f e j d f e j d f e j
 d f e j d f e j d f e j d f e j d	 f e j d	 f e j d
 f e j d
 f e j d f e j d f e j d f e j d f e j d f e j d f e j d f e j d f e j d f e j d f e j  d f e j! d f f  Z" e# d    Z$ e# d    Z% e& d    Z' e& d    Z( e& d    Z) d   Z* d d  Z+ d   Z, e, Z- d   Z. d   Z/ d   Z0 d d d  Z1 d   Z2 d   Z3 RS(   s   
    mixin implementing the selection & aggregation interface on a group-like
    object sub-classes need to define: obj, exclusions
    R6   t   __setstate__RA   t   maxt   mint   allt   anyt   meant   prodt   stdt   vart   mediant   cumprodt   cumsumc         C   s   |  j  d k r d S|  j  Sd S(   s   
        return a name for myself; this would ideally be called
        the 'name' property, but we cannot conflict with the
        Series.name property which can be set
        N(   t
   _selectionR8   (   R"   (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyt   _selection_name   s    c         C   s5   t  |  j t t t t t j f  s. |  j g S|  j S(   N(   t
   isinstanceRa   t   listt   tupleR   R   t   npt   ndarray(   R"   (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyt   _selection_list   s    
c         C   s:   |  j  d  k s! t |  j t  r( |  j S|  j |  j  Sd  S(   N(   Ra   R8   Rc   t   objR   (   R"   (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyt   _selected_obj   s    !c         C   s
   |  j  j S(   N(   Rj   t   ndim(   R"   (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyRk      s    c         C   sp   |  j  d  k	 r7 t |  j t  r7 |  j j d |  j  St |  j  d k re |  j j	 |  j d d S|  j Sd  S(   Nt   columnsi    t   axisi   (
   Ra   R8   Rc   Ri   R   t   reindexRh   t   lent
   exclusionst   drop(   R"   (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyt   _obj_with_exclusions   s    	c         C   sj  |  j  d  k	 r- t d j d |  j     n  t | t t t t t	 j
 f  r t |  j j j |   t |  k r t t |  j |  j j   } t d j d t |  d d !   n  |  j t |  d d St |  d	 t  s)| |  j j k rt d
 j d |    n  |  j | d d S| |  j k rSt d
 j d |    n  |  j | d d Sd  S(   Ns&   Column(s) {selection} already selectedt	   selections   Columns not found: {missing}t   missingi   iRk   i   t   as_indexs   Column not found: {key}R;   (   Ra   R8   t
   IndexErrorRO   Rc   Rd   Re   R   R   Rf   Rg   Ro   Ri   Rl   t   intersectiont   sett
   differencet   KeyErrorR-   t   _gotitemR7   RK   (   R"   R;   t   bad_keys(    (    s/   lib/python2.7/site-packages/pandas/core/base.pyt   __getitem__   s"    '!c         C   s   t  |    d S(   s  
        sub-classes to define
        return a sliced object

        Parameters
        ----------
        key : string / list of selections
        ndim : 1,2
            requested ndim of result
        subset : object, default None
            subset to act on

        N(   R   (   R"   R;   Rk   t   subset(    (    s/   lib/python2.7/site-packages/pandas/core/base.pyR{     s    c         O   s   t  |    d  S(   N(   R   (   R"   t   funct   argst   kwargs(    (    s/   lib/python2.7/site-packages/pandas/core/base.pyt	   aggregate&  s    c         O   s   t  | t j  s t  t |  | d  } | d k	 r t |  rO | | |   St |  d k sg t  t g  | D] } | d k rq | ^ qq  d k s t  | St t | d  } | d k	 r | |  | |  St	 d j
 d |    d S(   s   
        if arg is a string, then try to operate on it:
        - try to find a function (or attribute) on ourselves
        - try to find a numpy function
        - raise

        i    Rm   t   _levels#   {arg} is an unknown string functiont   argN(   Rm   R   (   Rc   R$   t   string_typest   AssertionErrorR7   R8   t   callableRo   Rf   t
   ValueErrorRO   (   R"   R   R   R   t   ft   kwarg(    (    s/   lib/python2.7/site-packages/pandas/core/base.pyt   _try_aggregate_string_function+  s    'c            s  d    t  } | j d d  } | d k rB t  d d  } n  | j d d   t | t j  r  j | | |  d f St | t  rC| d k r t	 d   n   j
  d d  } t  f d	   t j |  D  rt j   } x t j |  D] \ } }	 t |	 t t t f  s3|	 g | | <n
 |	 | | <t |	 t  rt } |  j k rd
 j d |  }
 t |
   n  | d  pd  q t  t  r|   q t  t  r |  j k r t d j d |    q q W| } nR t t j |   } t  t  rJt  j j |   t |  k rJ|   n  d d l m } d   f d      f d   } d   } t t j |   } t j    | rFt | |    j     t d    D  r+t j     } x | D] }  j |  qWt t j    } q j  d k	 rd } qn  j  d k	 rt!  j"  } t |  d k r| |    f d     qt | t! |   s| |     q| | |   n6 y | |     Wn  t k
 r| | |   n X f d   }  f d   } t  t  rS|  d | d d d t t f S|   r| g  | D] }  | ^ qfd | d d t f St  t  r|   ry |    Wn t# k
 rt	 d   n X t f Sd d l$ m% } m& } y |    Wn/ t	 k
 r8|  d t  d d   n X t f St' |  r}| t j k r} j( | d  d | d f Sd   j) |  } | r| r| rt  |    d f S t f S(   s  
        provide an implementation for the aggregators

        Parameters
        ----------
        arg : string, dict, function
        *args : args to pass on to the function
        **kwargs : kwargs to pass on to the function

        Returns
        -------
        tuple of result, how

        Notes
        -----
        how can be a string describe the required post-processing, or
        None if not required
        c         S   s   t  |  t t t f  S(   N(   Rc   Rd   Re   t   dict(   t   x(    (    s/   lib/python2.7/site-packages/pandas/core/base.pyt   <lambda>Z  s    t   _axisRm   i    R   s   Can only pass dict with axis=0i   c         S   s   t  j d t d |  d  S(   NsP   using a dict with renaming is deprecated and will be removed in a future versiont
   stacklevel(   t   warningst   warnt   FutureWarning(   t   level(    (    s/   lib/python2.7/site-packages/pandas/core/base.pyt   nested_renaming_deprn  s    c         3   s   |  ] }   |  Vq d  S(   N(    (   t   .0R   (   t   is_aggregator(    s/   lib/python2.7/site-packages/pandas/core/base.pys	   <genexpr>z  s    s:   cannot perform renaming for {key} with a nested dictionaryR;   s   Column '{col}' does not exist!t   coli(   t   concatc            sV    j  |  d d d | } | j d k r9 t d   n  | j | d   pN d d S(   s<   
                aggregate a 1-dim with how
                Rk   i   R~   s-   nested dictionary is ambiguous in aggregationR   i    (   R{   Rk   RS   R   (   t   namet   howR~   t   colg(   R   R"   (    s/   lib/python2.7/site-packages/pandas/core/base.pyt	   _agg_1dim  s    c            s1    j   j d d d   } | j | d d S(   s<   
                aggregate a 2-dim with how
                Rk   i   R~   R   N(   R{   Ra   R   R8   (   R   R   R   (   Ri   R"   (    s/   lib/python2.7/site-packages/pandas/core/base.pyt	   _agg_2dim  s    	c         S   sC   t  j   } x0 t  j |   D] \ } } | | |  | | <q W| S(   ss   
                run the aggregations over the arg with func
                return an OrderedDict
                (   R$   R   t	   iteritems(   R   R   t   resultt   fnamet   agg_how(    (    s/   lib/python2.7/site-packages/pandas/core/base.pyt   _agg  s    c         s   s   |  ] } t  | t  Vq d  S(   N(   Rc   R   (   R   t   r(    (    s/   lib/python2.7/site-packages/pandas/core/base.pys	   <genexpr>  s    i   c            s      j  |  S(   N(   Ra   (   R   R   (   R   R"   (    s/   lib/python2.7/site-packages/pandas/core/base.pyR     s    c              s   t  d   t j    D  S(   Nc         s   s   |  ] } t  | t  Vq d  S(   N(   Rc   R   (   R   R   (    (    s/   lib/python2.7/site-packages/pandas/core/base.pys	   <genexpr>  s   (   RY   R$   t
   itervalues(    (   R   (    s/   lib/python2.7/site-packages/pandas/core/base.pyt   is_any_series  s    	c              s   t  d   t j    D  S(   Nc         s   s   |  ] } t  | t  Vq d  S(   N(   Rc   R   (   R   R   (    (    s/   lib/python2.7/site-packages/pandas/core/base.pys	   <genexpr>  s   (   RY   R$   R   (    (   R   (    s/   lib/python2.7/site-packages/pandas/core/base.pyt   is_any_frame   s    	t   keyst   sortsL   cannot perform both aggregation and transformation operations simultaneously(   t	   DataFramet   SeriesR   N(*   RK   R:   R8   R7   Rc   R$   R   R   R   R   Rj   RY   R   R   R   Re   Rd   R@   Rl   RO   RS   R   R   Rz   t   iterkeysRo   Rw   t   pandas.core.reshape.concatR   t   valuesRX   t   updateRa   Rx   Rh   t	   TypeErrort   pandasR   R   R   t   _aggregate_multiple_funcst   _is_cython_func(   R"   R   R   R   t   is_nested_renamerR   R   t   new_argt   kt   vt   msgR   R   R   R   t   resultsR   t   slR   R   R   R   R   (    (   R   R   R   Ri   R   R"   s/   lib/python2.7/site-packages/pandas/core/base.pyt
   _aggregateG  s    		%
		
	$

	"	 
	
c      	   C   sd  d d l  m } | d k r+ t d   n  |  j j d k rI |  j } n	 |  j } g  } g  } | j d k rxJ| D] } yZ |  j | j d d d | }	 | j |	 j	 |   t
 j |  p | }
 | j |
  Wqt t t f k
 r qt t k
 r   qt Xqt Wn x t |  D] \ } } yU |  j | d d d | j d  d   | f }	 | j |	 j	 |   | j |  Wqt t f k
 rqt k
 rqqt k
 r  qXqWt |  st d   n  y  | | d	 | d
 d d t SWnh t k
 r_d d l m } d d l m } | | d | d |  j } | |  r[t d   n  | SXd  S(   Ni(   R   i    s"   axis other than 0 is not supportedi   Rk   R~   s
   no resultsR   Rm   R   (   t   is_nested_object(   R   t   indexR   s3   cannot combine transform and aggregation operations(   R   R   t   NotImplementedErrorRj   Rk   Rr   R{   R   t   appendR   t   comt   get_callable_nameR   RR   RS   t	   enumeratet   ilocR   Ro   RK   t   pandas.core.dtypes.castR   R   R   (   R"   R   R   R   R   Ri   R   R   t   aR   R   R   R   R   R   R   (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyR   :  sT    	 c         K   s   | d k r |  j j   } n  | d k r6 |  j } n  t | |  rQ | j } n  x3 |  j D]( } | | k r[ t |  |  | | <q[ q[ W| | |  S(   sE   
        return a new object with the replacement attributes
        N(   R8   Rj   t   copyR4   Rc   Ri   t   _attributesR7   (   R"   Ri   t   obj_typeR   t   attr(    (    s/   lib/python2.7/site-packages/pandas/core/base.pyt   _shallow_copyz  s    c         C   s   |  j  j |  S(   sP   
        if we define an internal function for this argument, return it
        (   t   _cython_tablet   get(   R"   R   (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyR     s    c         C   s   |  j  j | |  S(   sq   
        if we define an builtin function for this argument, return it,
        otherwise return the arg
        (   t   _builtin_tableR   (   R"   R   (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyt   _is_builtin_func  s    N(4   R/   R0   R1   R8   Ra   t   _internal_namesRx   t   _internal_names_setR   R   RA   Rf   RV   RW   R   RX   RY   t   nansumRZ   t   nanmeanR[   t   nanprodR\   t   nanstdR]   t   nanvarR^   t	   nanmediant   nanmaxt   nanminR_   t
   nancumprodR`   t	   nancumsumR   RF   Rb   Rh   R	   Rj   Rk   Rr   R}   R{   R   t   aggR   R   R   R   R   R   (    (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyRT      sb   					@	c        
   B   s  e  Z d  Z d Z d   Z e e d d Z e d    Z e d    Z e d    Z	 d   Z
 e d	    Z e d
    Z e d    Z e d    Z e d    Z e d    Z e d    Z e d    Z d8 e d  Z e d    Z e d    Z d8 e d  Z d8 e d  Z d8 e d  Z d8 e d  Z d   Z e Z d   Z e  d    Z! d e d8 d8 d  Z" d8 d  Z# e e e d8 e d  Z$ d   Z% e d   Z& e d!    Z' e d"    Z( e( Z) e d#    Z* e d$  Z+ e, d% d& d' d& d( d& d) e- j. d*   e/ e0 j1 d+  e d, d-    Z2 d. e1 d/ <e, d0 d1  e/ e1 d/  d2 d8 d3    Z3 d4 e d5  Z4 d4 d6  Z5 d7   Z6 RS(9   sS    common ops mixin to support a unified interface / docs for Series /
    Index
    i  c         O   s   t  j | |  |  S(   sD   
        Return the transpose, which is by definition self.
        (   t   nvt   validate_transpose(   R"   R   R   (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyt	   transpose  s    t   docs2   Return the transpose, which is by definition self.c         C   s   t  S(   sY  
        Whether the object has a single dtype.

        By definition, Series and Index are always considered homogeneous.
        A MultiIndex may or may not be homogeneous, depending on the
        dtypes of the levels.

        See Also
        --------
        DataFrame._is_homogeneous_type
        MultiIndex._is_homogeneous_type
        (   R@   (   R"   (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyt   _is_homogeneous_type  s    c         C   s
   |  j  j S(   sE   
        Return a tuple of the shape of the underlying data.
        (   t   _valuest   shape(   R"   (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyR     s    c         C   s   d S(   sO   
        Number of dimensions of the underlying data, by definition 1.
        i   (    (   R"   (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyRk     s    c         C   s5   y |  j  j   SWn t k
 r0 t d   n Xd S(   sU   
        Return the first element of the underlying data as a python scalar.
        s6   can only convert an array of size 1 to a Python scalarN(   R   t   itemRv   R   (   R"   (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyR     s    c         C   s5   t  j d j d t |   j  t d d |  j j S(   sA   
        Return the data pointer of the underlying data.
        s@   {obj}.data is deprecated and will be removed in a future versionRi   R   i   (   R   R   RO   RL   R/   R   R   t   data(   R"   (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyR     s    c         C   s5   t  j d j d t |   j  t d d |  j j S(   sR   
        Return the size of the dtype of the item of the underlying data.
        sD   {obj}.itemsize is deprecated and will be removed in a future versionRi   R   i   (   R   R   RO   RL   R/   R   t   _ndarray_valuest   itemsize(   R"   (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyR     s    c         C   s
   |  j  j S(   sD   
        Return the number of bytes in the underlying data.
        (   R   t   nbytes(   R"   (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyR     s    c         C   s5   t  j d j d t |   j  t d d |  j j S(   s<   
        Return the strides of the underlying data.
        sC   {obj}.strides is deprecated and will be removed in a future versionRi   R   i   (   R   R   RO   RL   R/   R   R   t   strides(   R"   (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyR     s    c         C   s   t  |  j  S(   sG   
        Return the number of elements in the underlying data.
        (   Ro   R   (   R"   (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyt   size  s    c         C   s5   t  j d j d t |   j  t d d |  j j S(   sC   
        Return the ndarray.flags for the underlying data.
        sA   {obj}.flags is deprecated and will be removed in a future versionRi   R   i   (   R   R   RO   RL   R/   R   R   t   flags(   R"   (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyR     s    c         C   s5   t  j d j d t |   j  t d d |  j j S(   sX   
        Return the base object if the memory of the underlying data is shared.
        s@   {obj}.base is deprecated and will be removed in a future versionRi   R   i   (   R   R   RO   RL   R/   R   R   t   base(   R"   (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyR     s    c         C   s   |  j  } t | j  r7 d d l m } | |  } n\ t | j  re d d l m } | |  } n. t | j  s d d l m	 } | |  } n  | S(   s  
        The ExtensionArray of the data backing this Series or Index.

        .. versionadded:: 0.24.0

        Returns
        -------
        array : ExtensionArray
            An ExtensionArray of the values stored within. For extension
            types, this is the actual array. For NumPy native types, this
            is a thin (no copy) wrapper around :class:`numpy.ndarray`.

            ``.array`` differs ``.values`` which may require converting the
            data to a different form.

        See Also
        --------
        Index.to_numpy : Similar method that always returns a NumPy array.
        Series.to_numpy : Similar method that always returns a NumPy array.

        Notes
        -----
        This table lays out the different array types for each extension
        dtype within pandas.

        ================== =============================
        dtype              array type
        ================== =============================
        category           Categorical
        period             PeriodArray
        interval           IntervalArray
        IntegerNA          IntegerArray
        datetime64[ns, tz] DatetimeArray
        ================== =============================

        For any 3rd-party extension types, the array type will be an
        ExtensionArray.

        For all remaining dtypes ``.array`` will be a
        :class:`arrays.NumpyExtensionArray` wrapping the actual ndarray
        stored within. If you absolutely need a NumPy array (possibly with
        copying / coercing data), then use :meth:`Series.to_numpy` instead.

        Examples
        --------

        For regular NumPy types like int, and float, a PandasArray
        is returned.

        >>> pd.Series([1, 2, 3]).array
        <PandasArray>
        [1, 2, 3]
        Length: 3, dtype: int64

        For extension types, like Categorical, the actual ExtensionArray
        is returned

        >>> ser = pd.Series(pd.Categorical(['a', 'b', 'a']))
        >>> ser.array
        [a, b, a]
        Categories (2, object): [a, b]
        i(   t   DatetimeArray(   t   TimedeltaArray(   t   PandasArray(
   R   R   t   dtypet   pandas.arraysR   R   R   R   t   pandas.core.arrays.numpy_R   (   R"   R   R   R   R   (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyt   array  s    A	c         C   sU   t  |  j  r$ | d k r$ d } n  t j |  j d | } | rQ | j   } n  | S(   s  
        A NumPy ndarray representing the values in this Series or Index.

        .. versionadded:: 0.24.0


        Parameters
        ----------
        dtype : str or numpy.dtype, optional
            The dtype to pass to :meth:`numpy.asarray`
        copy : bool, default False
            Whether to ensure that the returned value is a not a view on
            another array. Note that ``copy=False`` does not *ensure* that
            ``to_numpy()`` is no-copy. Rather, ``copy=True`` ensure that
            a copy is made, even if not strictly necessary.

        Returns
        -------
        numpy.ndarray

        See Also
        --------
        Series.array : Get the actual data stored within.
        Index.array : Get the actual data stored within.
        DataFrame.to_numpy : Similar method for DataFrame.

        Notes
        -----
        The returned array will be the same up to equality (values equal
        in `self` will be equal in the returned array; likewise for values
        that are not equal). When `self` contains an ExtensionArray, the
        dtype may be different. For example, for a category-dtype Series,
        ``to_numpy()`` will return a NumPy array and the categorical dtype
        will be lost.

        For NumPy dtypes, this will be a reference to the actual data stored
        in this Series or Index (assuming ``copy=False``). Modifying the result
        in place will modify the data stored in the Series or Index (not that
        we recommend doing that).

        For extension types, ``to_numpy()`` *may* require copying data and
        coercing the result to a NumPy type (possibly object), which may be
        expensive. When you need a no-copy reference to the underlying data,
        :attr:`Series.array` should be used instead.

        This table lays out the different dtypes and default return types of
        ``to_numpy()`` for various dtypes within pandas.

        ================== ================================
        dtype              array type
        ================== ================================
        category[T]        ndarray[T] (same dtype as input)
        period             ndarray[object] (Periods)
        interval           ndarray[object] (Intervals)
        IntegerNA          ndarray[object]
        datetime64[ns]     datetime64[ns]
        datetime64[ns, tz] ndarray[object] (Timestamps)
        ================== ================================

        Examples
        --------
        >>> ser = pd.Series(pd.Categorical(['a', 'b', 'a']))
        >>> ser.to_numpy()
        array(['a', 'b', 'a'], dtype=object)

        Specify the `dtype` to control how datetime-aware data is represented.
        Use ``dtype=object`` to return an ndarray of pandas :class:`Timestamp`
        objects, each with the correct ``tz``.

        >>> ser = pd.Series(pd.date_range('2000', periods=2, tz="CET"))
        >>> ser.to_numpy(dtype=object)
        array([Timestamp('2000-01-01 00:00:00+0100', tz='CET', freq='D'),
               Timestamp('2000-01-02 00:00:00+0100', tz='CET', freq='D')],
              dtype=object)

        Or ``dtype='datetime64[ns]'`` to return an ndarray of native
        datetime64 values. The values are converted to UTC and the timezone
        info is dropped.

        >>> ser.to_numpy(dtype="datetime64[ns]")
        ... # doctest: +ELLIPSIS
        array(['1999-12-31T23:00:00.000000000', '2000-01-01T23:00:00...'],
              dtype='datetime64[ns]')
        R5   R   N(   R   R   R8   Rf   t   asarrayR   R   (   R"   R   R   R   (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyt   to_numpyb  s    U	c         C   s   t  |   r |  j j S|  j S(   s   
        The data as an ndarray, possibly losing information.

        The expectation is that this is cheap to compute, and is primarily
        used for interacting with our indexers.

        - categorical -> codes
        (   R   R   R   R   (   R"   (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyR     s    
c         C   s   |  j  S(   N(   R   (   R"   (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyt   empty  s    c         C   s#   t  j |  t j |  j d | S(   sv  
        Return the maximum value of the Index.

        Parameters
        ----------
        axis : int, optional
            For compatibility with NumPy. Only 0 or None are allowed.
        skipna : bool, default True

        Returns
        -------
        scalar
            Maximum value.

        See Also
        --------
        Index.min : Return the minimum value in an Index.
        Series.max : Return the maximum value in a Series.
        DataFrame.max : Return the maximum values in a DataFrame.

        Examples
        --------
        >>> idx = pd.Index([3, 2, 1])
        >>> idx.max()
        3

        >>> idx = pd.Index(['c', 'b', 'a'])
        >>> idx.max()
        'c'

        For a MultiIndex, the maximum is determined lexicographically.

        >>> idx = pd.MultiIndex.from_product([('a', 'b'), (2, 1)])
        >>> idx.max()
        ('b', 2)
        t   skipna(   R   t   validate_minmax_axist   nanopsR   R   (   R"   Rm   R   (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyRV     s    %c         C   s#   t  j |  t j |  j d | S(   s  
        Return a ndarray of the maximum argument indexer.

        Parameters
        ----------
        axis : {None}
            Dummy argument for consistency with Series
        skipna : bool, default True

        See Also
        --------
        numpy.ndarray.argmax
        R   (   R   R   R   t	   nanargmaxR   (   R"   Rm   R   (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyt   argmax  s    c         C   s#   t  j |  t j |  j d | S(   sb  
        Return the minimum value of the Index.

        Parameters
        ----------
        axis : {None}
            Dummy argument for consistency with Series
        skipna : bool, default True

        Returns
        -------
        scalar
            Minimum value.

        See Also
        --------
        Index.max : Return the maximum value of the object.
        Series.min : Return the minimum value in a Series.
        DataFrame.min : Return the minimum values in a DataFrame.

        Examples
        --------
        >>> idx = pd.Index([3, 2, 1])
        >>> idx.min()
        1

        >>> idx = pd.Index(['c', 'b', 'a'])
        >>> idx.min()
        'a'

        For a MultiIndex, the minimum is determined lexicographically.

        >>> idx = pd.MultiIndex.from_product([('a', 'b'), (2, 1)])
        >>> idx.min()
        ('a', 1)
        R   (   R   R   R   R   R   (   R"   Rm   R   (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyRW     s    %c         C   s#   t  j |  t j |  j d | S(   s  
        Return a ndarray of the minimum argument indexer.

        Parameters
        ----------
        axis : {None}
            Dummy argument for consistency with Series
        skipna : bool, default True

        See Also
        --------
        numpy.ndarray.argmin
        R   (   R   R   R   t	   nanargminR   (   R"   Rm   R   (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyt   argmin7  s    c         C   s_   t  |  j  r2 g  |  j D] } t j |  ^ q St |  j  rN t |  j  S|  j j   Sd S(   s  
        Return a list of the values.

        These are each a scalar type, which is a Python scalar
        (for str, int, float) or a pandas scalar
        (for Timestamp/Timedelta/Interval/Period)

        See Also
        --------
        numpy.ndarray.tolist
        N(   R   R   R   t   maybe_box_datetimelikeR   Rd   t   tolist(   R"   R   (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyR   H  s
    #c         C   sa   t  |  j  r" t t j |  j  St |  j  r> t |  j  St |  j j t |  j j	   Sd S(   s   
        Return an iterator of the values.

        These are each a scalar type, which is a Python scalar
        (for str, int, float) or a pandas scalar
        (for Timestamp/Timedelta/Interval/Period)
        N(
   R   R   R   R   R   R   t   iterR   R   R   (   R"   (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyt   __iter__]  s
    	c         C   s   t  t |   j    S(   sK   
        Return if I have any nans; enables various perf speedups.
        (   t   boolR   RY   (   R"   (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyt   hasnansm  s    i    c   	      K   sU   t  |  | d  } | d k rE t d j d |  j j d |    n  | d | |  S(   s0    perform the reduction type operation if we can s)   {klass} cannot perform the operation {op}R   t   opR   N(   R7   R8   R   RO   R3   R/   (	   R"   R  R   Rm   R   t   numeric_onlyt   filter_typet   kwdsR   (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyt   _reducet  s
    c            sA  t  | t  rU t | d  r6 |     f d   } qU d d l m } | |  } n  t  | t  r t |  j  r |  j } n	 |  j	 } | j
 j |  } t j | j |  } | St |  j  r |  j } | d	 k	 r t  n  d   } nB |  j t  } t | d |  } | d k r%d   } n	 t j } | | |  } | S(
   s  
        An internal function that maps values using the input
        correspondence (which can be a dict, Series, or function).

        Parameters
        ----------
        mapper : function, dict, or Series
            The input correspondence object
        na_action : {None, 'ignore'}
            If 'ignore', propagate NA values, without passing them to the
            mapping function

        Returns
        -------
        applied : Union[Index, MultiIndex], inferred
            The output of the mapping function applied to the index.
            If the function returns a tuple with more than one element
            a MultiIndex will be returned.

        t   __missing__c            s     |  S(   N(    (   R   (   t   dict_with_default(    s/   lib/python2.7/site-packages/pandas/core/base.pyR     s    i(   R   c         S   s   |  j  |  S(   N(   R   (   R   R   (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyR     s    R   t   ignorec         S   s%   t  j |  | t |   j t j   S(   N(   t   libt   map_infer_maskR   t   viewRf   t   uint8(   R   R   (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyt   map_f  s    N(   Rc   R   R?   R   R   R   R   R   R   R   R   t   get_indexerR   t   take_1dR8   R   t   astypeR5   R7   R  t	   map_infer(   R"   t   mappert	   na_actionR   R   t   indexert
   new_valuesR  (    (   R	  s/   lib/python2.7/site-packages/pandas/core/base.pyt   _map_values}  s2    				c         C   s>   d d l  m } | |  d | d | d | d | d | } | S(   s  
        Return a Series containing counts of unique values.

        The resulting object will be in descending order so that the
        first element is the most frequently-occurring element.
        Excludes NA values by default.

        Parameters
        ----------
        normalize : boolean, default False
            If True then the object returned will contain the relative
            frequencies of the unique values.
        sort : boolean, default True
            Sort by values.
        ascending : boolean, default False
            Sort in ascending order.
        bins : integer, optional
            Rather than count values, group them into half-open bins,
            a convenience for ``pd.cut``, only works with numeric data.
        dropna : boolean, default True
            Don't include counts of NaN.

        Returns
        -------
        counts : Series

        See Also
        --------
        Series.count: Number of non-NA elements in a Series.
        DataFrame.count: Number of non-NA elements in a DataFrame.

        Examples
        --------
        >>> index = pd.Index([3, 1, 2, 3, 4, np.nan])
        >>> index.value_counts()
        3.0    2
        4.0    1
        2.0    1
        1.0    1
        dtype: int64

        With `normalize` set to `True`, returns the relative frequency by
        dividing all values by the sum of values.

        >>> s = pd.Series([3, 1, 2, 3, 4, np.nan])
        >>> s.value_counts(normalize=True)
        3.0    0.4
        4.0    0.2
        2.0    0.2
        1.0    0.2
        dtype: float64

        **bins**

        Bins can be useful for going from a continuous variable to a
        categorical variable; instead of counting unique
        apparitions of values, divide the index in the specified
        number of half-open bins.

        >>> s.value_counts(bins=3)
        (2.0, 3.0]      2
        (0.996, 2.0]    2
        (3.0, 4.0]      1
        dtype: int64

        **dropna**

        With `dropna` set to `False` we can also see NaN index values.

        >>> s.value_counts(dropna=False)
        3.0    2
        NaN    1
        4.0    1
        2.0    1
        1.0    1
        dtype: int64
        i(   t   value_countsR   t	   ascendingt	   normalizet   binst   dropna(   t   pandas.core.algorithmsR  (   R"   R  R   R  R  R  R  R   (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyR    s    Oc         C   sG   |  j  } t | d  r' | j   } n d d l m } | |  } | S(   NR   i(   t   unique1d(   R   R?   R   R  R  (   R"   R   R   R  (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyR     s    	c         C   sA   |  j    } t |  } | r= t |  j   r= | d 8} n  | S(   s  
        Return number of unique elements in the object.

        Excludes NA values by default.

        Parameters
        ----------
        dropna : boolean, default True
            Don't include NaN in the count.

        Returns
        -------
        nunique : int
        i   (   R   Ro   R   RY   (   R"   R  t   uniqst   n(    (    s/   lib/python2.7/site-packages/pandas/core/base.pyt   nunique&  s
    c         C   s   |  j  d t  t |   k S(   s   
        Return boolean if values in the object are unique.

        Returns
        -------
        is_unique : boolean
        R  (   R"  RK   Ro   (   R"   (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyt	   is_unique;  s    	c         C   s   d d l  m } | |   j S(   s   
        Return boolean if values in the object are
        monotonic_increasing.

        .. versionadded:: 0.19.0

        Returns
        -------
        is_monotonic : boolean
        i(   t   Index(   R   R$  t   is_monotonic(   R"   R$  (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyR%  F  s    c         C   s   d d l  m } | |   j S(   s   
        Return boolean if values in the object are
        monotonic_decreasing.

        .. versionadded:: 0.19.0

        Returns
        -------
        is_monotonic_decreasing : boolean
        i(   R$  (   R   R$  t   is_monotonic_decreasing(   R"   R$  (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyR&  W  s    c         C   sg   t  |  j d  r% |  j j d |  S|  j j } | rc t |   rc t rc | t j |  j  7} n  | S(   s  
        Memory usage of the values

        Parameters
        ----------
        deep : bool
            Introspect the data deeply, interrogate
            `object` dtypes for system-level memory consumption

        Returns
        -------
        bytes used

        See Also
        --------
        numpy.ndarray.nbytes

        Notes
        -----
        Memory usage does not include memory consumed by elements that
        are not components of the array if deep=False or if used on PyPy
        R=   R>   (   R?   R   R=   R   R   R    R  t   memory_usage_of_objects(   R"   R>   R   (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyR=   f  s    R   R   t   ordert	   size_hintR   s               sort : boolean, default False
                Sort `uniques` and shuffle `labels` to maintain the
                relationship.
            t	   factorizeic         C   s   t  j |  d | d | S(   NR   t   na_sentinel(   R   R*  (   R"   R   R+  (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyR*    s    	sl  
        Find indices where elements should be inserted to maintain order.

        Find the indices into a sorted %(klass)s `self` such that, if the
        corresponding elements in `value` were inserted before the indices,
        the order of `self` would be preserved.

        Parameters
        ----------
        value : array_like
            Values to insert into `self`.
        side : {'left', 'right'}, optional
            If 'left', the index of the first suitable location found is given.
            If 'right', return the last such index.  If there is no suitable
            index, return either 0 or N (where N is the length of `self`).
        sorter : 1-D array_like, optional
            Optional array of integer indices that sort `self` into ascending
            order. They are typically the result of ``np.argsort``.

        Returns
        -------
        int or array of int
            A scalar or array of insertion points with the
            same shape as `value`.

            .. versionchanged :: 0.24.0
                If `value` is a scalar, an int is now always returned.
                Previously, scalar inputs returned an 1-item array for
                :class:`Series` and :class:`Categorical`.

        See Also
        --------
        numpy.searchsorted

        Notes
        -----
        Binary search is used to find the required insertion points.

        Examples
        --------

        >>> x = pd.Series([1, 2, 3])
        >>> x
        0    1
        1    2
        2    3
        dtype: int64

        >>> x.searchsorted(4)
        3

        >>> x.searchsorted([0, 4])
        array([0, 3])

        >>> x.searchsorted([1, 3], side='left')
        array([0, 2])

        >>> x.searchsorted([1, 3], side='right')
        array([1, 3])

        >>> x = pd.Categorical(['apple', 'bread', 'bread',
                                'cheese', 'milk'], ordered=True)
        [apple, bread, bread, cheese, milk]
        Categories (4, object): [apple < bread < cheese < milk]

        >>> x.searchsorted('bread')
        1

        >>> x.searchsorted(['bread'], side='right')
        array([3])
        t   searchsortedR   R   t   leftc         C   s   |  j  j | d | d | S(   Nt   sidet   sorter(   R   R,  (   R"   RP   R.  R/  (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyR,    s    t   firstc         C   st   t  | d  } t |  t  r4 |  j r4 |  j   Sn  |  j d |  } |  t j |  } | rl |  j |  S| Sd  S(   NR   t   keep(	   R
   Rc   R   R#  R   R    Rf   t   logical_nott   _update_inplace(   R"   R1  R   R    R   (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyt   drop_duplicates  s    	c         C   s   d d l  m } t |  t  rT |  j rD t j t |   d t j S| |  d | S|  j	 | |  d | d |  j
 j |   Sd  S(   Ni(   R    R   R1  R   (   R  R    Rc   R   R#  Rf   t   zerosRo   R  R4   R   t   __finalize__(   R"   R1  R    (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyR      s    	c         K   s   t  |    d  S(   N(   R   (   R"   R   R   (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyR3    s    N(7   R/   R0   R1   t   __array_priority__R   RF   t   TR   R   Rk   R   R   R   R   R   R   R   R   R   R8   RK   R   R   R   R@   RV   R   RW   R   R   t   to_listR   R	   R  R  R  R  R   R"  R#  R%  t   is_monotonic_increasingR&  R=   R   t   textwrapt   dedentR   R   t   _shared_docsR*  R,  R4  R    R3  (    (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyR     sh   		




Pa((			I	S		J
(@   R1   R;  R   t   numpyRf   t   pandas._libs.libt   _libsR  t   pandas.compatR$   R    R   R   R   R   t   pandas.compat.numpyR   R   t   pandas.errorsR   t   pandas.util._decoratorsR   R   R	   t   pandas.util._validatorsR
   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   t   pandas.coreR   R   R   t   pandas.core.accessorR   t   pandas.core.nanopst   coreR   R   R=  t   _indexops_doc_kwargsR5   R!   R2   RG   t	   ExceptionRQ   RR   RS   RT   R   (    (    (    s/   lib/python2.7/site-packages/pandas/core/base.pyt   <module>   s8   (@	0. 