
x\c           @   sI  d  d l  Z  d  d l Z d  d l Z d  d l Z d  d l Z d  d l j j Z d  d l	 j j
 Z d  d l j Z d  d l m Z d  d l m Z 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 d  d l m  Z  d  d l! m" Z" d  d l# m$ Z$ d  d l% j& j' Z( d= Z) e) d> Z* e+   Z, d   Z- e j. e/ d  Z0 e1 e j. e/ d  Z2 d d  Z3 e4 d e j. e4 d  Z5 e j. d  Z6 e j. d  Z7 d  d d e4 d  Z9 d   Z: e4 d e j. d  Z; d   Z< d   Z= d d  Z> d d   Z? d e4 d!  Z@ d d"  ZA d# d$  ZB d%   ZC d d&  ZD d d d' d(  ZE d d d' d)  ZF d' d* d+  ZG d d d,  ZH d d d-  ZI d d d d.  ZJ d d d d/  ZK d d0 d1  ZL d2   ZM d d3  ZN d4   ZO d5 d6  ZP d5 d7  ZQ d d8  ZR e1 e1 d9  ZS d:   ZT d; e$ f d<     YZU d S(?   iN(   t   zip(   t   Appendert   deprecate_kwarg(	   t   ensure_objectt   is_bool_dtypet   is_categorical_dtypet
   is_integert   is_list_liket   is_object_dtypet   is_ret	   is_scalart   is_string_like(   t   ABCIndexClasst	   ABCSeries(   t   isna(   t   take_1d(   t   NoNewAttributesMixins   utf-8t   utf8s   latin-1t   latin1s
   iso-8859-1t   mbcst   asciis   utf-16s   utf-32c         C   sA   | g d t  |   d } |  | d d d  <t j | d d S(   s  
    Auxiliary function for :meth:`str.cat`

    Parameters
    ----------
    list_of_columns : list of numpy arrays
        List of arrays to be concatenated with sep;
        these arrays may not contain NaNs!
    sep : string
        The separator string for concatenating the columns

    Returns
    -------
    nd.array
        The concatenation of list_of_columns with sep
    i   i   Nt   axisi    (   t   lent   npt   sum(   t   list_of_columnst   sept   list_with_sep(    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyt   cat_core#   s    c      	   C   s   t  |  | d t d | d | S(   Nt   na_maskt   na_valuet   dtype(   t   _mapt   True(   t   ft   arrt	   na_resultR   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyt   _na_map9   s    c            s  t  |  s t j d d | St | t  r: | j } n  t | t j  sd t j | d t } n  | rt |  } y5 t	 |  } t
 j |   | j t j  |  } Wn t t f k
 r7} t j r d }	 n d }	 t  | j  d k rt j |	 | j d  r|  n     f d   }
 t |
 | d | SX t j k	 r~t j | |   | j t k r~t
 j |  } q~n  | St
 j |    Sd  S(   Ni    R   s4   takes (no|(exactly|at (least|most)) ?\d+) arguments?sO   ((takes)|(missing)) (?(2)from \d+ to )?\d+ (?(3)required )positional arguments?i   c            s-   y   |   SWn t  t f k
 r(  SXd  S(   N(   t	   TypeErrort   AttributeError(   t   x(   R"   R   (    s2   lib/python2.7/site-packages/pandas/core/strings.pyt   gW   s    (   R   R   t   ndarrayt
   isinstanceR   t   valuest   asarrayt   objectR   t   allt   libt   map_infer_maskt   viewt   uint8R&   R'   t   compatt   PY2t   argst   ret   searchR    t   nant   putmaskR   t   maybe_convert_objectst	   map_infer(   R"   R#   R   R   R   t   maskt   convertt   resultt   et   p_errR)   (    (   R"   R   s2   lib/python2.7/site-packages/pandas/core/strings.pyR    >   s2    (		.	i    c            s7   t  j | d |     f d   } t | |  d t S(   s  
    Count occurrences of pattern in each string of the Series/Index.

    This function is used to count the number of times a particular regex
    pattern is repeated in each of the string elements of the
    :class:`~pandas.Series`.

    Parameters
    ----------
    pat : str
        Valid regular expression.
    flags : int, default 0, meaning no flags
        Flags for the `re` module. For a complete list, `see here
        <https://docs.python.org/3/howto/regex.html#compilation-flags>`_.
    **kwargs
        For compatibility with other string methods. Not used.

    Returns
    -------
    counts : Series or Index
        Same type as the calling object containing the integer counts.

    See Also
    --------
    re : Standard library module for regular expressions.
    str.count : Standard library version, without regular expression support.

    Notes
    -----
    Some characters need to be escaped when passing in `pat`.
    eg. ``'$'`` has a special meaning in regex and must be escaped when
    finding this literal character.

    Examples
    --------
    >>> s = pd.Series(['A', 'B', 'Aaba', 'Baca', np.nan, 'CABA', 'cat'])
    >>> s.str.count('a')
    0    0.0
    1    0.0
    2    2.0
    3    2.0
    4    NaN
    5    0.0
    6    1.0
    dtype: float64

    Escape ``'$'`` to find the literal dollar sign.

    >>> s = pd.Series(['$', 'B', 'Aab$', '$$ca', 'C$B$', 'cat'])
    >>> s.str.count('\$')
    0    1
    1    0
    2    1
    3    2
    4    2
    5    0
    dtype: int64

    This is also available on Index

    >>> pd.Index(['A', 'A', 'Aaba', 'cat']).str.count('a')
    Int64Index([0, 0, 2, 1], dtype='int64')
    t   flagsc            s   t    j |    S(   N(   R   t   findall(   R(   (   t   regex(    s2   lib/python2.7/site-packages/pandas/core/strings.pyt   <lambda>   s    R   (   R7   t   compileR%   t   int(   R#   t   patRB   R"   (    (   RD   s2   lib/python2.7/site-packages/pandas/core/strings.pyt	   str_countg   s    @c            s    rk | s | t  j O} n  t  j   d |   j d k rY t j d t d d n   f d   } n[ | r   f d   } nC   j     f d   } t d	   |   } t | | | d
 t	 St | |  | d
 t	 S(   s"  
    Test if pattern or regex is contained within a string of a Series or Index.

    Return boolean Series or Index based on whether a given pattern or regex is
    contained within a string of a Series or Index.

    Parameters
    ----------
    pat : str
        Character sequence or regular expression.
    case : bool, default True
        If True, case sensitive.
    flags : int, default 0 (no flags)
        Flags to pass through to the re module, e.g. re.IGNORECASE.
    na : default NaN
        Fill value for missing values.
    regex : bool, default True
        If True, assumes the pat is a regular expression.

        If False, treats the pat as a literal string.

    Returns
    -------
    Series or Index of boolean values
        A Series or Index of boolean values indicating whether the
        given pattern is contained within the string of each element
        of the Series or Index.

    See Also
    --------
    match : Analogous, but stricter, relying on re.match instead of re.search.
    Series.str.startswith : Test if the start of each string element matches a
        pattern.
    Series.str.endswith : Same as startswith, but tests the end of string.

    Examples
    --------

    Returning a Series of booleans using only a literal pattern.

    >>> s1 = pd.Series(['Mouse', 'dog', 'house and parrot', '23', np.NaN])
    >>> s1.str.contains('og', regex=False)
    0    False
    1     True
    2    False
    3    False
    4      NaN
    dtype: object

    Returning an Index of booleans using only a literal pattern.

    >>> ind = pd.Index(['Mouse', 'dog', 'house and parrot', '23.0', np.NaN])
    >>> ind.str.contains('23', regex=False)
    Index([False, False, False, True, nan], dtype='object')

    Specifying case sensitivity using `case`.

    >>> s1.str.contains('oG', case=True, regex=True)
    0    False
    1    False
    2    False
    3    False
    4      NaN
    dtype: object

    Specifying `na` to be `False` instead of `NaN` replaces NaN values
    with `False`. If Series or Index does not contain NaN values
    the resultant dtype will be `bool`, otherwise, an `object` dtype.

    >>> s1.str.contains('og', na=False, regex=True)
    0    False
    1     True
    2    False
    3    False
    4    False
    dtype: bool

    Returning 'house' or 'dog' when either expression occurs in a string.

    >>> s1.str.contains('house|dog', regex=True)
    0    False
    1     True
    2     True
    3    False
    4      NaN
    dtype: object

    Ignoring case sensitivity using `flags` with regex.

    >>> import re
    >>> s1.str.contains('PARROT', flags=re.IGNORECASE, regex=True)
    0    False
    1    False
    2     True
    3    False
    4      NaN
    dtype: object

    Returning any digit using regular expression.

    >>> s1.str.contains('\d', regex=True)
    0    False
    1    False
    2    False
    3     True
    4      NaN
    dtype: object

    Ensure `pat` is a not a literal pattern when `regex` is set to True.
    Note in the following example one might expect only `s2[1]` and `s2[3]` to
    return `True`. However, '.0' as a regex matches any character
    followed by a 0.

    >>> s2 = pd.Series(['40','40.0','41','41.0','35'])
    >>> s2.str.contains('.0', regex=True)
    0     True
    1     True
    2    False
    3     True
    4    False
    dtype: bool
    RB   i    sK   This pattern has match groups. To actually get the groups, use str.extract.t
   stackleveli   c            s   t    j |    S(   N(   t   boolR8   (   R(   (   RD   (    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE   2  s    c            s
     |  k S(   N(    (   R(   (   RH   (    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE   5  s    c            s
     |  k S(   N(    (   R(   (   t	   upper_pat(    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE   8  s    c         S   s
   |  j    S(   N(   t   upper(   R(   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE   9  s    R   (
   R7   t
   IGNORECASERF   t   groupst   warningst   warnt   UserWarningRM   R%   RK   (   R#   RH   t   caseRB   t   naRD   R"   t   uppered(    (   RH   RD   RL   s2   lib/python2.7/site-packages/pandas/core/strings.pyt   str_contains   s     {	
c            s%     f d   } t  | |  | d t S(   s  
    Test if the start of each string element matches a pattern.

    Equivalent to :meth:`str.startswith`.

    Parameters
    ----------
    pat : str
        Character sequence. Regular expressions are not accepted.
    na : object, default NaN
        Object shown if element tested is not a string.

    Returns
    -------
    Series or Index of bool
        A Series of booleans indicating whether the given pattern matches
        the start of each string element.

    See Also
    --------
    str.startswith : Python standard library string method.
    Series.str.endswith : Same as startswith, but tests the end of string.
    Series.str.contains : Tests if string element contains a pattern.

    Examples
    --------
    >>> s = pd.Series(['bat', 'Bear', 'cat', np.nan])
    >>> s
    0     bat
    1    Bear
    2     cat
    3     NaN
    dtype: object

    >>> s.str.startswith('b')
    0     True
    1    False
    2    False
    3      NaN
    dtype: object

    Specifying `na` to be `False` instead of `NaN`.

    >>> s.str.startswith('b', na=False)
    0     True
    1    False
    2    False
    3    False
    dtype: bool
    c            s   |  j     S(   N(   t
   startswith(   R(   (   RH   (    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE   q  s    R   (   R%   RK   (   R#   RH   RT   R"   (    (   RH   s2   lib/python2.7/site-packages/pandas/core/strings.pyt   str_startswith>  s    3c            s%     f d   } t  | |  | d t S(   sw  
    Test if the end of each string element matches a pattern.

    Equivalent to :meth:`str.endswith`.

    Parameters
    ----------
    pat : str
        Character sequence. Regular expressions are not accepted.
    na : object, default NaN
        Object shown if element tested is not a string.

    Returns
    -------
    Series or Index of bool
        A Series of booleans indicating whether the given pattern matches
        the end of each string element.

    See Also
    --------
    str.endswith : Python standard library string method.
    Series.str.startswith : Same as endswith, but tests the start of string.
    Series.str.contains : Tests if string element contains a pattern.

    Examples
    --------
    >>> s = pd.Series(['bat', 'bear', 'caT', np.nan])
    >>> s
    0     bat
    1    bear
    2     caT
    3     NaN
    dtype: object

    >>> s.str.endswith('t')
    0     True
    1    False
    2    False
    3      NaN
    dtype: object

    Specifying `na` to be `False` instead of `NaN`.

    >>> s.str.endswith('t', na=False)
    0     True
    1    False
    2    False
    3    False
    dtype: bool
    c            s   |  j     S(   N(   t   endswith(   R(   (   RH   (    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE     s    R   (   R%   RK   (   R#   RH   RT   R"   (    (   RH   s2   lib/python2.7/site-packages/pandas/core/strings.pyt   str_endswithu  s    3c   	         ss  t    p t   s' t d   n  t   } | r!| ri | d k	 sW | d k r t d   q n1 | d k r~ t } n  | t k r | t j	 O} n  | s t
   d k s | s t   r	 d k r  n d  t j  d |       f d   } qf   f d   } nE | r6t d   n  t   rQt d	   n     f d
   } t | |   S(   s  
    Replace occurrences of pattern/regex in the Series/Index with
    some other string. Equivalent to :meth:`str.replace` or
    :func:`re.sub`.

    Parameters
    ----------
    pat : string or compiled regex
        String can be a character sequence or regular expression.

        .. versionadded:: 0.20.0
            `pat` also accepts a compiled regex.

    repl : string or callable
        Replacement string or a callable. The callable is passed the regex
        match object and must return a replacement string to be used.
        See :func:`re.sub`.

        .. versionadded:: 0.20.0
            `repl` also accepts a callable.

    n : int, default -1 (all)
        Number of replacements to make from start
    case : boolean, default None
        - If True, case sensitive (the default if `pat` is a string)
        - Set to False for case insensitive
        - Cannot be set if `pat` is a compiled regex
    flags : int, default 0 (no flags)
        - re module flags, e.g. re.IGNORECASE
        - Cannot be set if `pat` is a compiled regex
    regex : boolean, default True
        - If True, assumes the passed-in pattern is a regular expression.
        - If False, treats the pattern as a literal string
        - Cannot be set to False if `pat` is a compiled regex or `repl` is
          a callable.

        .. versionadded:: 0.23.0

    Returns
    -------
    Series or Index of object
        A copy of the object with all matching occurrences of `pat` replaced by
        `repl`.

    Raises
    ------
    ValueError
        * if `regex` is False and `repl` is a callable or `pat` is a compiled
          regex
        * if `pat` is a compiled regex and `case` or `flags` is set

    Notes
    -----
    When `pat` is a compiled regex, all flags should be included in the
    compiled regex. Use of `case`, `flags`, or `regex=False` with a compiled
    regex will raise an error.

    Examples
    --------
    When `pat` is a string and `regex` is True (the default), the given `pat`
    is compiled as a regex. When `repl` is a string, it replaces matching
    regex patterns as with :meth:`re.sub`. NaN value(s) in the Series are
    left as is:

    >>> pd.Series(['foo', 'fuz', np.nan]).str.replace('f.', 'ba', regex=True)
    0    bao
    1    baz
    2    NaN
    dtype: object

    When `pat` is a string and `regex` is False, every `pat` is replaced with
    `repl` as with :meth:`str.replace`:

    >>> pd.Series(['f.o', 'fuz', np.nan]).str.replace('f.', 'ba', regex=False)
    0    bao
    1    fuz
    2    NaN
    dtype: object

    When `repl` is a callable, it is called on every `pat` using
    :func:`re.sub`. The callable should expect one positional argument
    (a regex object) and return a string.

    To get the idea:

    >>> pd.Series(['foo', 'fuz', np.nan]).str.replace('f', repr)
    0    <_sre.SRE_Match object; span=(0, 1), match='f'>oo
    1    <_sre.SRE_Match object; span=(0, 1), match='f'>uz
    2                                                  NaN
    dtype: object

    Reverse every lowercase alphabetic word:

    >>> repl = lambda m: m.group(0)[::-1]
    >>> pd.Series(['foo 123', 'bar baz', np.nan]).str.replace(r'[a-z]+', repl)
    0    oof 123
    1    rab zab
    2        NaN
    dtype: object

    Using regex groups (extract second group and swap case):

    >>> pat = r"(?P<one>\w+) (?P<two>\w+) (?P<three>\w+)"
    >>> repl = lambda m: m.group('two').swapcase()
    >>> pd.Series(['One Two Three', 'Foo Bar Baz']).str.replace(pat, repl)
    0    tWO
    1    bAR
    dtype: object

    Using a compiled regex with flags

    >>> regex_pat = re.compile(r'FUZ', flags=re.IGNORECASE)
    >>> pd.Series(['foo', 'fuz', np.nan]).str.replace(regex_pat, 'bar')
    0    foo
    1    bar
    2    NaN
    dtype: object
    s!   repl must be a string or callablei    s9   case and flags cannot be set when pat is a compiled regexi   RB   c            s     j  d  d |  d   S(   Nt   replt   stringt   count(   t   sub(   R(   (   t   compiledt   nR[   (    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE   :  s    c            s   |  j       S(   N(   t   replace(   R(   (   R`   RH   R[   (    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE   <  s    sC   Cannot use a compiled regex as replacement pattern with regex=Falses2   Cannot use a callable replacement when regex=Falsec            s   |  j       S(   N(   Ra   (   R(   (   R`   RH   R[   (    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE   D  s    N(   R   t   callableR&   R	   t   Nonet
   ValueErrorR!   t   FalseR7   RN   R   RF   R%   (	   R#   RH   R[   R`   RS   RB   RD   t   is_compiled_reR"   (    (   R_   R`   RH   R[   s2   lib/python2.7/site-packages/pandas/core/strings.pyt   str_replace  s,    y	*c            sl   t     r(   f d   } t | |   Sd   } t j   d t   t j t j |     |  } | Sd S(   s  
    Duplicate each string in the Series or Index.

    Parameters
    ----------
    repeats : int or sequence of int
        Same value for all (int) or different value per (sequence).

    Returns
    -------
    Series or Index of object
        Series or Index of repeated string objects specified by
        input parameter repeats.

    Examples
    --------
    >>> s = pd.Series(['a', 'b', 'c'])
    >>> s
    0    a
    1    b
    2    c

    Single int repeats string in Series

    >>> s.str.repeat(repeats=2)
    0    aa
    1    bb
    2    cc

    Sequence of int repeats corresponding string in Series

    >>> s.str.repeat(repeats=[1, 2, 3])
    0      a
    1     bb
    2    ccc
    c            s?   y t  j j |     SWn! t k
 r: t  j j |     SXd  S(   N(   R4   t   binary_typet   __mul__R&   t	   text_type(   R(   (   t   repeats(    s2   lib/python2.7/site-packages/pandas/core/strings.pyt   repo  s    c         S   s?   y t  j j |  |  SWn! t k
 r: t  j j |  |  SXd  S(   N(   R4   Rh   Ri   R&   Rj   (   R(   t   r(    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyRl   x  s    R   N(	   R
   R%   R   R-   R.   t   libopst	   vec_binopt   comt   values_from_object(   R#   Rk   Rl   R?   (    (   Rk   s2   lib/python2.7/site-packages/pandas/core/strings.pyt
   str_repeatI  s    %	c            sV   | s | t  j O} n  t  j | d |   t }   f d   } t | |  | d | S(   sB  
    Determine if each string matches a regular expression.

    Parameters
    ----------
    pat : string
        Character sequence or regular expression
    case : boolean, default True
        If True, case sensitive
    flags : int, default 0 (no flags)
        re module flags, e.g. re.IGNORECASE
    na : default NaN, fill value for missing values

    Returns
    -------
    Series/array of boolean values

    See Also
    --------
    contains : Analogous, but less strict, relying on re.search instead of
        re.match.
    extract : Extract matched groups.
    RB   c            s   t    j |    S(   N(   RK   t   match(   R(   (   RD   (    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE     s    R   (   R7   RN   RF   RK   R%   (   R#   RH   RS   RB   RT   R   R"   (    (   RD   s2   lib/python2.7/site-packages/pandas/core/strings.pyt	   str_match  s    c         C   s6   y t  |  j j    j   SWn t k
 r1 d  SXd  S(   N(   t   listt
   groupindext   keyst   popt
   IndexErrorRc   (   t   rx(    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyt   _get_single_group_name  s    c            sG    j  d k r t d   n  t j g  j       f d   } | S(   s/   Used in both extract_noexpand and extract_framei    s"   pattern contains no capture groupsc            se   t  |  t j  s   S j |   } | r] g  | j   D]! } | d  k rS t j n | ^ q8 S  Sd  S(   N(   R+   R4   t   string_typesR8   RO   Rc   R   R9   (   R(   t   mt   item(   t	   empty_rowRD   (    s2   lib/python2.7/site-packages/pandas/core/strings.pyR"     s    2(   RO   Rd   R   R9   (   RD   R"   (    (   R   RD   s2   lib/python2.7/site-packages/pandas/core/strings.pyt   _groups_or_na_fun  s
    c         C   si  d d l  m } m } t j | d | } t |  } | j d k r t j g  |  D] } | |  d ^ qS d t	 } t
 |  }	 n t |  |  r t d   n  d
 }	 t t | j j   | j j     }
 g  t | j  D] } |
 j d | |  ^ q } |  j r%| d | d t	  } n: | g  |  D] } | |  ^ q/d | d	 |  j d t	 } | |	 f S(   s   
    Find groups in each string in the Series using passed regular
    expression. This function is called from
    str_extract(expand=False), and can return Series, DataFrame, or
    Index.

    i(   t	   DataFramet   IndexRB   i   i    R   s,   only one regex group is supported with Indext   columnst   indexN(   t   pandasR   R   R7   RF   R   RO   R   t   arrayR.   R{   R+   Rd   Rc   t   dictR    Rv   R,   Rw   t   ranget   gett   emptyR   (   R#   RH   RB   R   R   RD   t   groups_or_nat   valR?   t   namet   namest   iR   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyt   _str_extract_noexpand  s&    2'2			c         C   s  d d l  m } t j | d | } t |  } t t | j j   | j j	     } g  t
 | j  D] } | j d | |  ^ qh } t |   d k r | d | d t  Sy |  j }	 Wn t k
 r d	 }	 n X| g  |  D] }
 | |
  ^ q d | d |	 d t S(
   s   
    For each subject string in the Series, extract groups from the
    first match of regular expression pat. This function is called from
    str_extract(expand=True), and always returns a DataFrame.

    i(   R   RB   i   i    R   R   R   N(   R   R   R7   RF   R   R   R    Rv   R,   Rw   R   RO   R   R   R.   R   R'   Rc   (   R#   RH   RB   R   RD   R   R   R   R   t   result_indexR   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyt   _str_extract_frame  s     '2
c         C   su   t  | t  s t d   n  | r: t |  j | d | St |  j | d | \ } } |  j | d | d | Sd S(   sO	  
    Extract capture groups in the regex `pat` as columns in a DataFrame.

    For each subject string in the Series, extract groups from the
    first match of regular expression `pat`.

    Parameters
    ----------
    pat : string
        Regular expression pattern with capturing groups.
    flags : int, default 0 (no flags)
        Flags from the ``re`` module, e.g. ``re.IGNORECASE``, that
        modify regular expression matching for things like case,
        spaces, etc. For more details, see :mod:`re`.
    expand : bool, default True
        If True, return DataFrame with one column per capture group.
        If False, return a Series/Index if there is one capture group
        or DataFrame if there are multiple capture groups.

        .. versionadded:: 0.18.0

    Returns
    -------
    DataFrame or Series or Index
        A DataFrame with one row for each subject string, and one
        column for each group. Any capture group names in regular
        expression pat will be used for column names; otherwise
        capture group numbers will be used. The dtype of each result
        column is always object, even when no match is found. If
        ``expand=False`` and pat has only one capture group, then
        return a Series (if subject is a Series) or Index (if subject
        is an Index).

    See Also
    --------
    extractall : Returns all matches (not just the first match).

    Examples
    --------
    A pattern with two groups will return a DataFrame with two columns.
    Non-matches will be NaN.

    >>> s = pd.Series(['a1', 'b2', 'c3'])
    >>> s.str.extract(r'([ab])(\d)')
         0    1
    0    a    1
    1    b    2
    2  NaN  NaN

    A pattern may contain optional groups.

    >>> s.str.extract(r'([ab])?(\d)')
         0  1
    0    a  1
    1    b  2
    2  NaN  3

    Named groups will become column names in the result.

    >>> s.str.extract(r'(?P<letter>[ab])(?P<digit>\d)')
      letter digit
    0      a     1
    1      b     2
    2    NaN   NaN

    A pattern with one group will return a DataFrame with one column
    if expand=True.

    >>> s.str.extract(r'[ab](\d)', expand=True)
         0
    0    1
    1    2
    2  NaN

    A pattern with one group will return a Series if expand=False.

    >>> s.str.extract(r'[ab](\d)', expand=False)
    0      1
    1      2
    2    NaN
    dtype: object
    s   expand must be True or FalseRB   R   t   expandN(   R+   RK   Rd   R   t   _origR   t   _parentt   _wrap_result(   R#   RH   RB   R   R?   R   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyt   str_extract  s    Sc         C   s  t  j | d | } | j d k r3 t d   n  t |  t  r] |  j   j d t  }  n  t	 t
 | j j   | j j     } g  t | j  D] } | j d | |  ^ q } g  } g  } |  j j d k }	 x |  j   D] \ }
 } t | t j  r |	 s|
 f }
 n  x t | j |   D] \ } } t | t j  rQ| f } n  g  | D]! } | d k rst j n | ^ qX} | j |  t |
 | f  } | j |  q'Wq q Wd d l m } | j | d	 |  j j d
 g } |  j | d | d | } | S(   s  
    For each subject string in the Series, extract groups from all
    matches of regular expression pat. When each subject string in the
    Series has exactly one match, extractall(pat).xs(0, level='match')
    is the same as extract(pat).

    .. versionadded:: 0.18.0

    Parameters
    ----------
    pat : str
        Regular expression pattern with capturing groups.
    flags : int, default 0 (no flags)
        A ``re`` module flag, for example ``re.IGNORECASE``. These allow
        to modify regular expression matching for things like case, spaces,
        etc. Multiple flags can be combined with the bitwise OR operator,
        for example ``re.IGNORECASE | re.MULTILINE``.

    Returns
    -------
    DataFrame
        A ``DataFrame`` with one row for each match, and one column for each
        group. Its rows have a ``MultiIndex`` with first levels that come from
        the subject ``Series``. The last level is named 'match' and indexes the
        matches in each item of the ``Series``. Any capture group names in
        regular expression pat will be used for column names; otherwise capture
        group numbers will be used.

    See Also
    --------
    extract : Returns first match only (not all matches).

    Examples
    --------
    A pattern with one group will return a DataFrame with one column.
    Indices with no matches will not appear in the result.

    >>> s = pd.Series(["a1a2", "b1", "c1"], index=["A", "B", "C"])
    >>> s.str.extractall(r"[ab](\d)")
             0
      match
    A 0      1
      1      2
    B 0      1

    Capture group names are used for column names of the result.

    >>> s.str.extractall(r"[ab](?P<digit>\d)")
            digit
      match
    A 0         1
      1         2
    B 0         1

    A pattern with two groups will return a DataFrame with two columns.

    >>> s.str.extractall(r"(?P<letter>[ab])(?P<digit>\d)")
            letter digit
      match
    A 0          a     1
      1          a     2
    B 0          b     1

    Optional groups that do not match are NaN in the result.

    >>> s.str.extractall(r"(?P<letter>[ab])?(?P<digit>\d)")
            letter digit
      match
    A 0          a     1
      1          a     2
    B 0          b     1
    C 0        NaN     1
    RB   i    s"   pattern contains no capture groupst   dropi   t    i(   t
   MultiIndexR   Rs   R   R   (    R7   RF   RO   Rd   R+   R   t	   to_seriest   reset_indexR!   R   R    Rv   R,   Rw   R   R   R   t   nlevelst	   iteritemsR4   R|   t	   enumerateRC   R   t   NaNt   appendt   tupleR   R   t   from_tuplesR   t   _constructor_expanddim(   R#   RH   RB   RD   R   R   R   t
   match_listt
   index_listt   is_mit   subject_keyt   subjectt   match_it   match_tuplet   groupt   na_tuplet
   result_keyR   R   R?   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyt   str_extractallV  s8    K'2"+	t   |c            s  |  j  d  }  y | |  | }  Wn( t k
 rK | |  j t  | }  n Xt   } x' |  j j |  D] } | j |  qh Wt | d h  } t j	 t
 |   t
 |  f d t j } xV t |  D]H \ } } | | |   t j |  j   f d    | d d  | f <q W| | f S(   s#  
    Split each string in the Series by sep and return a frame of
    dummy/indicator variables.

    Parameters
    ----------
    sep : string, default "|"
        String to split on.

    Returns
    -------
    dummies : DataFrame

    See Also
    --------
    get_dummies

    Examples
    --------
    >>> pd.Series(['a|b', 'a', 'a|c']).str.get_dummies()
       a  b  c
    0  1  1  0
    1  1  0  0
    2  1  0  1

    >>> pd.Series(['a|b', np.nan, 'a|c']).str.get_dummies()
       a  b  c
    0  1  1  0
    1  0  0  0
    2  1  0  1
    R   R   c            s
     |  k S(   N(    (   R(   (   RH   (    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE     s    N(   t   fillnaR&   t   astypet   strt   sett   splitt   updatet   sortedR   R   R   t   int64R   R0   R<   R,   (   R#   R   t   tagst   tst   dummiesR   t   t(    (   RH   s2   lib/python2.7/site-packages/pandas/core/strings.pyt   str_get_dummies  s     	*2c         C   s   t  | j |   S(   s  
    Join lists contained as elements in the Series/Index with passed delimiter.

    If the elements of a Series are lists themselves, join the content of these
    lists using the delimiter passed to the function.
    This function is an equivalent to :meth:`str.join`.

    Parameters
    ----------
    sep : str
        Delimiter to use between list entries.

    Returns
    -------
    Series/Index: object
        The list entries concatenated by intervening occurrences of the
        delimiter.

    Raises
    -------
    AttributeError
        If the supplied Series contains neither strings nor lists.

    See Also
    --------
    str.join : Standard library version of this method.
    Series.str.split : Split strings around given separator/delimiter.

    Notes
    -----
    If any of the list items is not a string object, the result of the join
    will be `NaN`.

    Examples
    --------
    Example with a list that contains non-string elements.

    >>> s = pd.Series([['lion', 'elephant', 'zebra'],
    ...                [1.1, 2.2, 3.3],
    ...                ['cat', np.nan, 'dog'],
    ...                ['cow', 4.5, 'goat'],
    ...                ['duck', ['swan', 'fish'], 'guppy']])
    >>> s
    0        [lion, elephant, zebra]
    1                [1.1, 2.2, 3.3]
    2                [cat, nan, dog]
    3               [cow, 4.5, goat]
    4    [duck, [swan, fish], guppy]
    dtype: object

    Join all lists using a '-'. The lists containing object(s) of types other
    than str will produce a NaN.

    >>> s.str.join('-')
    0    lion-elephant-zebra
    1                    NaN
    2                    NaN
    3                    NaN
    4                    NaN
    dtype: object
    (   R%   t   join(   R#   R   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyt   str_join  s    >c         C   s%   t  j | d | } t | j |   S(   s7	  
    Find all occurrences of pattern or regular expression in the Series/Index.

    Equivalent to applying :func:`re.findall` to all the elements in the
    Series/Index.

    Parameters
    ----------
    pat : string
        Pattern or regular expression.
    flags : int, default 0
        ``re`` module flags, e.g. `re.IGNORECASE` (default is 0, which means
        no flags).

    Returns
    -------
    Series/Index of lists of strings
        All non-overlapping matches of pattern or regular expression in each
        string of this Series/Index.

    See Also
    --------
    count : Count occurrences of pattern or regular expression in each string
        of the Series/Index.
    extractall : For each string in the Series, extract groups from all matches
        of regular expression and return a DataFrame with one row for each
        match and one column for each group.
    re.findall : The equivalent ``re`` function to all non-overlapping matches
        of pattern or regular expression in string, as a list of strings.

    Examples
    --------

    >>> s = pd.Series(['Lion', 'Monkey', 'Rabbit'])

    The search for the pattern 'Monkey' returns one match:

    >>> s.str.findall('Monkey')
    0          []
    1    [Monkey]
    2          []
    dtype: object

    On the other hand, the search for the pattern 'MONKEY' doesn't return any
    match:

    >>> s.str.findall('MONKEY')
    0    []
    1    []
    2    []
    dtype: object

    Flags can be added to the pattern or regular expression. For instance,
    to find the pattern 'MONKEY' ignoring the case:

    >>> import re
    >>> s.str.findall('MONKEY', flags=re.IGNORECASE)
    0          []
    1    [Monkey]
    2          []
    dtype: object

    When the pattern matches more than one string in the Series, all matches
    are returned:

    >>> s.str.findall('on')
    0    [on]
    1    [on]
    2      []
    dtype: object

    Regular expressions are supported too. For instance, the search for all the
    strings ending with the word 'on' is shown next:

    >>> s.str.findall('on$')
    0    [on]
    1      []
    2      []
    dtype: object

    If the pattern is found more than once in the same string, then a list of
    multiple strings is returned:

    >>> s.str.findall('b')
    0        []
    1        []
    2    [b, b]
    dtype: object
    RB   (   R7   RF   R%   RC   (   R#   RH   RB   RD   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyt   str_findall;  s    Zt   leftc            s   t   t j  s9 d } t | j t   j    n  | d k rN d  n! | d k rc d  n t d     d
 k r    f d   } n      f d   } t	 | |  d	 t
 S(   s  
    Return indexes in each strings in the Series/Index where the
    substring is fully contained between [start:end]. Return -1 on failure.

    Parameters
    ----------
    sub : str
        Substring being searched
    start : int
        Left edge index
    end : int
        Right edge index
    side : {'left', 'right'}, default 'left'
        Specifies a starting side, equivalent to ``find`` or ``rfind``

    Returns
    -------
    found : Series/Index of integer values
    s!   expected a string object, not {0}R   t   findt   rightt   rfinds   Invalid sidec            s   t  |        S(   N(   t   getattr(   R(   (   t   methodt   startR^   (    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE     s    c            s   t  |         S(   N(   R   (   R(   (   t   endR   R   R^   (    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE     s    R   N(   R+   R4   R|   R&   t   formatt   typet   __name__Rd   Rc   R%   RG   (   R#   R^   R   R   t   sidet   msgR"   (    (   R   R   R   R^   s2   lib/python2.7/site-packages/pandas/core/strings.pyt   str_find  s    !		c            s   t   t j  s9 d } t | j t   j    n  | d k rN d  n! | d k rc d  n t d     d  k r    f d   } n      f d   } t	 | |  d	 t
 S(
   Ns!   expected a string object, not {0}R   R   R   t   rindexs   Invalid sidec            s   t  |        S(   N(   R   (   R(   (   R   R   R^   (    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE     s    c            s   t  |         S(   N(   R   (   R(   (   R   R   R   R^   (    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE     s    R   (   R+   R4   R|   R&   R   R   R   Rd   Rc   R%   RG   (   R#   R^   R   R   R   R   R"   (    (   R   R   R   R^   s2   lib/python2.7/site-packages/pandas/core/strings.pyt	   str_index  s    !		t    c            s	  t    t j  s9 d } t | j t    j    n  t    d k rZ t d   n  t   s d } t | j t   j    n  | d k r    f d   } nN | d k r    f d   } n- | d	 k r    f d
   } n t	 d   t
 | |   S(   s>  
    Pad strings in the Series/Index up to width.

    Parameters
    ----------
    width : int
        Minimum width of resulting string; additional characters will be filled
        with character defined in `fillchar`.
    side : {'left', 'right', 'both'}, default 'left'
        Side from which to fill resulting string.
    fillchar : str, default ' '
        Additional character for filling, default is whitespace.

    Returns
    -------
    Series or Index of object
        Returns Series or Index with minimum number of char in object.

    See Also
    --------
    Series.str.rjust : Fills the left side of strings with an arbitrary
        character. Equivalent to ``Series.str.pad(side='left')``.
    Series.str.ljust : Fills the right side of strings with an arbitrary
        character. Equivalent to ``Series.str.pad(side='right')``.
    Series.str.center : Fills boths sides of strings with an arbitrary
        character. Equivalent to ``Series.str.pad(side='both')``.
    Series.str.zfill :  Pad strings in the Series/Index by prepending '0'
        character. Equivalent to ``Series.str.pad(side='left', fillchar='0')``.

    Examples
    --------
    >>> s = pd.Series(["caribou", "tiger"])
    >>> s
    0    caribou
    1      tiger
    dtype: object

    >>> s.str.pad(width=10)
    0       caribou
    1         tiger
    dtype: object

    >>> s.str.pad(width=10, side='right', fillchar='-')
    0    caribou---
    1    tiger-----
    dtype: object

    >>> s.str.pad(width=10, side='both', fillchar='-')
    0    -caribou--
    1    --tiger---
    dtype: object
    s%   fillchar must be a character, not {0}i   s%   fillchar must be a character, not strs&   width must be of integer type, not {0}R   c            s   |  j      S(   N(   t   rjust(   R(   (   t   fillchart   width(    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE     s    R   c            s   |  j      S(   N(   t   ljust(   R(   (   R   R   (    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE     s    t   bothc            s   |  j      S(   N(   t   center(   R(   (   R   R   (    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE     s    s   Invalid side(   R+   R4   R|   R&   R   R   R   R   R   Rd   R%   (   R#   R   R   R   R   R"   (    (   R   R   s2   lib/python2.7/site-packages/pandas/core/strings.pyt   str_pad  s     5!!c            s    d  k rB   d  k s$   d k r- d   n     f d   } n t   d k r   d  k sl   d k ru d   n     f d   } nB   d  k s   d k r d   n  t j       f d   } t | |   } | S(   Ni    ic            s   |  j      S(   N(   R   (   R(   (   R`   RH   (    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE   &  s    i   c            s   |  j      S(   N(   R   (   R(   (   R`   RH   (    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE   +  s    c            s    j  |  d   S(   Nt   maxsplit(   R   (   R(   (   R`   RD   (    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE   0  s    (   Rc   R   R7   RF   R%   (   R#   RH   R`   R"   t   res(    (   R`   RH   RD   s2   lib/python2.7/site-packages/pandas/core/strings.pyt	   str_split!  s    			c            sF     d  k s   d k r! d   n     f d   } t | |   } | S(   Ni    ic            s   |  j      S(   N(   t   rsplit(   R(   (   R`   RH   (    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE   9  s    (   Rc   R%   (   R#   RH   R`   R"   R   (    (   R`   RH   s2   lib/python2.7/site-packages/pandas/core/strings.pyt
   str_rsplit5  s
    	c            s.   t  | | |      f d   } t | |   S(   s"  
    Slice substrings from each element in the Series or Index.

    Parameters
    ----------
    start : int, optional
        Start position for slice operation.
    stop : int, optional
        Stop position for slice operation.
    step : int, optional
        Step size for slice operation.

    Returns
    -------
    Series or Index of object
        Series or Index from sliced substring from original string object.

    See Also
    --------
    Series.str.slice_replace : Replace a slice with a string.
    Series.str.get : Return element at position.
        Equivalent to `Series.str.slice(start=i, stop=i+1)` with `i`
        being the position.

    Examples
    --------
    >>> s = pd.Series(["koala", "fox", "chameleon"])
    >>> s
    0        koala
    1          fox
    2    chameleon
    dtype: object

    >>> s.str.slice(start=1)
    0        oala
    1          ox
    2    hameleon
    dtype: object

    >>> s.str.slice(stop=2)
    0    ko
    1    fo
    2    ch
    dtype: object

    >>> s.str.slice(step=2)
    0      kaa
    1       fx
    2    caeen
    dtype: object

    >>> s.str.slice(start=0, stop=5, step=3)
    0    kl
    1     f
    2    cm
    dtype: object

    Equivalent behaviour to:

    >>> s.str[0:5:3]
    0    kl
    1     f
    2    cm
    dtype: object
    c            s   |    S(   N(    (   R(   (   t   obj(    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE     s    (   t   sliceR%   (   R#   R   t   stopt   stepR"   (    (   R   s2   lib/python2.7/site-packages/pandas/core/strings.pyt	   str_slice>  s    Bc            s7     d k r d   n      f d   } t | |   S(   s  
    Replace a positional slice of a string with another value.

    Parameters
    ----------
    start : int, optional
        Left index position to use for the slice. If not specified (None),
        the slice is unbounded on the left, i.e. slice from the start
        of the string.
    stop : int, optional
        Right index position to use for the slice. If not specified (None),
        the slice is unbounded on the right, i.e. slice until the
        end of the string.
    repl : str, optional
        String for replacement. If not specified (None), the sliced region
        is replaced with an empty string.

    Returns
    -------
    replaced : Series or Index
        Same type as the original object.

    See Also
    --------
    Series.str.slice : Just slicing without replacement.

    Examples
    --------
    >>> s = pd.Series(['a', 'ab', 'abc', 'abdc', 'abcde'])
    >>> s
    0        a
    1       ab
    2      abc
    3     abdc
    4    abcde
    dtype: object

    Specify just `start`, meaning replace `start` until the end of the
    string with `repl`.

    >>> s.str.slice_replace(1, repl='X')
    0    aX
    1    aX
    2    aX
    3    aX
    4    aX
    dtype: object

    Specify just `stop`, meaning the start of the string to `stop` is replaced
    with `repl`, and the rest of the string is included.

    >>> s.str.slice_replace(stop=2, repl='X')
    0       X
    1       X
    2      Xc
    3     Xdc
    4    Xcde
    dtype: object

    Specify `start` and `stop`, meaning the slice from `start` to `stop` is
    replaced with `repl`. Everything before or after `start` and `stop` is
    included as is.

    >>> s.str.slice_replace(start=1, stop=3, repl='X')
    0      aX
    1      aX
    2      aX
    3     aXc
    4    aXde
    dtype: object
    R   c            sp   |    !d k r  } n  } d }  d  k	 rE | |    7} n  |   7}  d  k	 rl | |  | 7} n  | S(   NR   (   Rc   (   R(   t
   local_stopt   y(   R[   R   R   (    s2   lib/python2.7/site-packages/pandas/core/strings.pyR"     s    	
N(   Rc   R%   (   R#   R   R   R[   R"   (    (   R[   R   R   s2   lib/python2.7/site-packages/pandas/core/strings.pyt   str_slice_replace  s    H	R   c            ss   | d k r   f d   } nH | d k r<   f d   } n* | d k rZ   f d   } n t  d   t | |   S(   s  
    Strip whitespace (including newlines) from each string in the
    Series/Index.

    Parameters
    ----------
    to_strip : str or unicode
    side : {'left', 'right', 'both'}, default 'both'

    Returns
    -------
    stripped : Series/Index of objects
    R   c            s   |  j     S(   N(   t   strip(   R(   (   t   to_strip(    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE     s    R   c            s   |  j     S(   N(   t   lstrip(   R(   (   R   (    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE     s    R   c            s   |  j     S(   N(   t   rstrip(   R(   (   R   (    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE     s    s   Invalid side(   Rd   R%   (   R#   R   R   R"   (    (   R   s2   lib/python2.7/site-packages/pandas/core/strings.pyt	   str_strip  s    c            s/   | | d <t  j |     t   f d   |   S(   s%  
    Wrap long strings in the Series/Index to be formatted in
    paragraphs with length less than a given width.

    This method has the same keyword parameters and defaults as
    :class:`textwrap.TextWrapper`.

    Parameters
    ----------
    width : int
        Maximum line-width
    expand_tabs : bool, optional
        If true, tab characters will be expanded to spaces (default: True)
    replace_whitespace : bool, optional
        If true, each whitespace character (as defined by string.whitespace)
        remaining after tab expansion will be replaced by a single space
        (default: True)
    drop_whitespace : bool, optional
        If true, whitespace that, after wrapping, happens to end up at the
        beginning or end of a line is dropped (default: True)
    break_long_words : bool, optional
        If true, then words longer than width will be broken in order to ensure
        that no lines are longer than width. If it is false, long words will
        not be broken, and some lines may be longer than width. (default: True)
    break_on_hyphens : bool, optional
        If true, wrapping will occur preferably on whitespace and right after
        hyphens in compound words, as it is customary in English. If false,
        only whitespaces will be considered as potentially good places for line
        breaks, but you need to set break_long_words to false if you want truly
        insecable words. (default: True)

    Returns
    -------
    wrapped : Series/Index of objects

    Notes
    -----
    Internally, this method uses a :class:`textwrap.TextWrapper` instance with
    default settings. To achieve behavior matching R's stringr library str_wrap
    function, use the arguments:

    - expand_tabs = False
    - replace_whitespace = True
    - drop_whitespace = True
    - break_long_words = False
    - break_on_hyphens = False

    Examples
    --------

    >>> s = pd.Series(['line to be wrapped', 'another line to be wrapped'])
    >>> s.str.wrap(12)
    0             line to be\nwrapped
    1    another line\nto be\nwrapped
    R   c            s   d j    j |    S(   Ns   
(   R   t   wrap(   t   s(   t   tw(    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE   5  s    (   t   textwrapt   TextWrapperR%   (   R#   R   t   kwargs(    (   R   s2   lib/python2.7/site-packages/pandas/core/strings.pyt   str_wrap  s    8
c            sU     d k r  f d   } n* t j r6 t d   n     f d   } t | |   S(   sy  
    Map all characters in the string through the given mapping table.
    Equivalent to standard :meth:`str.translate`. Note that the optional
    argument deletechars is only valid if you are using python 2. For python 3,
    character deletion should be specified via the table argument.

    Parameters
    ----------
    table : dict (python 3), str or None (python 2)
        In python 3, table is a mapping of Unicode ordinals to Unicode
        ordinals, strings, or None. Unmapped characters are left untouched.
        Characters mapped to None are deleted. :meth:`str.maketrans` is a
        helper function for making translation tables.
        In python 2, table is either a string of length 256 or None. If the
        table argument is None, no translation is applied and the operation
        simply removes the characters in deletechars. :func:`string.maketrans`
        is a helper function for making translation tables.
    deletechars : str, optional (python 2)
        A string of characters to delete. This argument is only valid
        in python 2.

    Returns
    -------
    translated : Series/Index of objects
    c            s   |  j     S(   N(   t	   translate(   R(   (   t   table(    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE   S  s    s   deletechars is not a valid argument for str.translate in python 3. You should simply specify character deletions in the table argumentc            s   |  j      S(   N(   R   (   R(   (   t   deletecharsR   (    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE   Z  s    N(   Rc   R4   t   PY3Rd   R%   (   R#   R   R   R"   (    (   R   R   s2   lib/python2.7/site-packages/pandas/core/strings.pyt   str_translate8  s    	c            s     f d   } t  | |   S(   s  
    Extract element from each component at specified position.

    Extract element from lists, tuples, or strings in each element in the
    Series/Index.

    Parameters
    ----------
    i : int
        Position of element to extract.

    Returns
    -------
    items : Series/Index of objects

    Examples
    --------
    >>> s = pd.Series(["String",
               (1, 2, 3),
               ["a", "b", "c"],
               123, -456,
               {1:"Hello", "2":"World"}])
    >>> s
    0                        String
    1                     (1, 2, 3)
    2                     [a, b, c]
    3                           123
    4                          -456
    5    {1: 'Hello', '2': 'World'}
    dtype: object

    >>> s.str.get(1)
    0        t
    1        2
    2        b
    3      NaN
    4      NaN
    5    Hello
    dtype: object

    >>> s.str.get(-1)
    0      g
    1      3
    2      c
    3    NaN
    4    NaN
    5    NaN
    dtype: object
    c            sT   t  |  t  r |  j    St |     k o@ t |   k n rM |    St j S(   N(   R+   R   R   R   R   R9   (   R(   (   R   (    s2   lib/python2.7/site-packages/pandas/core/strings.pyR"     s
    )(   R%   (   R#   R   R"   (    (   R   s2   lib/python2.7/site-packages/pandas/core/strings.pyt   str_get^  s    2t   strictc            sO    t  k r!   f d   } n! t j        f d   } t | |   S(   s4  
    Decode character string in the Series/Index using indicated encoding.
    Equivalent to :meth:`str.decode` in python2 and :meth:`bytes.decode` in
    python3.

    Parameters
    ----------
    encoding : str
    errors : str, optional

    Returns
    -------
    decoded : Series/Index of objects
    c            s   |  j      S(   N(   t   decode(   R(   (   t   encodingt   errors(    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE     s    c            s     |    d S(   Ni    (    (   R(   (   t   decoderR   (    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE     s    (   t   _cpython_optimized_decoderst   codecst
   getdecoderR%   (   R#   R   R   R"   (    (   R   R   R   s2   lib/python2.7/site-packages/pandas/core/strings.pyt
   str_decode  s
    c            sO    t  k r!   f d   } n! t j        f d   } t | |   S(   s  
    Encode character string in the Series/Index using indicated encoding.
    Equivalent to :meth:`str.encode`.

    Parameters
    ----------
    encoding : str
    errors : str, optional

    Returns
    -------
    encoded : Series/Index of objects
    c            s   |  j      S(   N(   t   encode(   R(   (   R   R   (    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE     s    c            s     |    d S(   Ni    (    (   R(   (   t   encoderR   (    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE     s    (   t   _cpython_optimized_encodersR   t
   getencoderR%   (   R#   R   R   R"   (    (   R  R   R   s2   lib/python2.7/site-packages/pandas/core/strings.pyt
   str_encode  s
    c            sF      f d   }   j  | _  | d  k	 r6 | | _ n t d   | S(   Nc            s"   t    |  j   } |  j |  S(   N(   R%   R   R   (   t   selfR?   (   R"   t   kargs(    s2   lib/python2.7/site-packages/pandas/core/strings.pyt   wrapper  s    s   Provide docstring(   R   Rc   t   __doc__Rd   (   R"   t	   docstringR  R  (    (   R"   R  s2   lib/python2.7/site-packages/pandas/core/strings.pyt   _noarg_wrapper  s    c            s|     f d   } d   f d  } t  j   f d  } | rB | n | rN | n | }   j | _   j rx   j | _ n  | S(   Nc            s     |  j  |  } |  j |  S(   N(   R   R   (   R  RH   R?   (   R"   (    s2   lib/python2.7/site-packages/pandas/core/strings.pyt   wrapper1  s    i    c            s(     |  j  | d | | } |  j |  S(   NRB   (   R   R   (   R  RH   RB   R   R?   (   R"   (    s2   lib/python2.7/site-packages/pandas/core/strings.pyt   wrapper2  s    c            s%     |  j  | d | } |  j |  S(   NRT   (   R   R   (   R  RH   RT   R?   (   R"   (    s2   lib/python2.7/site-packages/pandas/core/strings.pyt   wrapper3  s    (   R   R9   R   R	  (   R"   RB   RT   R   R  R  R  R  (    (   R"   s2   lib/python2.7/site-packages/pandas/core/strings.pyt   _pat_wrapper  s    	c            s     f d   } | S(   s:   Copy a docstring from another source function (if present)c            s     j  r   j  |  _  n  |  S(   N(   R	  (   t   target(   t   source(    s2   lib/python2.7/site-packages/pandas/core/strings.pyt   do_copy  s    	(    (   R  R  (    (   R  s2   lib/python2.7/site-packages/pandas/core/strings.pyt   copy  s    t   StringMethodsc           B   s(	  e  Z d  Z d   Z e d    Z d   Z d   Z e e	 e	 e
 j d  Z e d  Z e	 e	 e	 e	 d  Z d e d	 <e e d	 i d
 d 6d d 6 e	 d e d   Z e e d	 i d d 6d d 6 e	 d e d   Z d e d <e e d i d d 6d d 6d d 6 e d d d d  d e d    Z e e d i d  d 6d! d 6d" d 6 e d d d d  d e d#    Z e e  d$    Z e e  d%    Z e e  e d& e
 j e d'   Z e e  e d& e
 j d(   Z e e   d e	 d& e d)   Z! e e"  d*    Z# e e$  d+ d d,   Z% d- e d. <e e d. e& d d/ d d0   d d1   Z' e e d. e& d d2 d d3   d d4   Z( e e d. e& d d+ d d5   d d6   Z) d7   Z* e e+  e	 e	 e	 d8   Z, e e-  e	 e	 e	 d9   Z. e e/  d: d;   Z0 e e1  d: d<   Z2 d= e d> <e e d> e& d d? d d@   e	 dA   Z3 e e d> e& d dB d dC   e	 dD   Z4 e e d> e& d dE d dF   e	 dG   Z5 e e6  dH    Z7 e e8  dI dJ   Z9 e e:  e	 dK   Z; e< e= dL e Z> e< e? dM e Z@ e< eA dM e ZB e< eC dL e ZD e eE  d& e dN   ZF e eG  d& dO   ZH dP e dQ <e e dQ e& d dR d dQ d dS   d& e	 dT   ZI e e dQ e& d dU d dV d dW   d& e	 dX   ZJ dY   ZK dZ e d[ <e e d[ e& d dR d\ dQ d d[ d d]   d& e	 d^   ZL e e d[ e& d dU d\ dV d d_ d d`   d& e	 da   ZM db e dc <eN eO dd e dc de eP ZO df e dg <e& dh di d dj  e dj <e& dh dk d dl  e dl <e& dh dm d dn  e dn <e& dh do d dp  e dp <e& dh dq d dr  e dr <eN ds   dd e dg e dj ZQ eN dt   dd e dg e dl ZR eN du   dd e dg e dn ZS eN dv   dd e dg e dp ZT eN dw   dd e dg e dr ZU dx e dy <e& dh dz d d{  e d{ <e& dh d| d d}  e d} <e& dh d~ d d  e d <e& dh d d d  e d <e& dh di d d  e d <e& dh dk d d  e d <e& dh dm d d  e d <e& dh d d d  e d <e& dh d d d  e d <eN d   dd e dy e d{ ZV eN d   dd e dy e d} ZW eN d   dd e dy e d ZX eN d   dd e dy e d ZY eN d   dd e dy e d ZZ eN d   dd e dy e d Z[ eN d   dd e dy e d Z\ eN d   dd e dy e d Z] eN d   dd e dy e d Z^ e_ d    Z` RS(   s,  
    Vectorized string functions for Series and Index. NAs stay NA unless
    handled otherwise by a particular method. Patterned after Python's string
    methods, with some inspiration from R's stringr package.

    Examples
    --------
    >>> s.str.split('_')
    >>> s.str.replace('_', '')
    c         C   sQ   |  j  |  t |  |  _ |  j r1 | j j n | |  _ | |  _ |  j   d  S(   N(   t	   _validateR   t   _is_categoricalR,   t
   categoriesR   R   t   _freeze(   R  t   data(    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyt   __init__  s
    	c         C   s   d d l  m } t |  t  r_ t |  j  r@ t |  j j  pL t |  j  r_ t	 d   n t |  |  r d } t |  j  r |  j j
 } n	 |  j
 } | | k r d } t	 |   n  |  j d	 k r d
 } t	 |   q n  d  S(   Ni(   R   sS   Can only use .str accessor with string values, which use np.object_ dtype in pandasR\   t   unicodet   mixeds   mixed-integersd   Can only use .str accessor with string values (i.e. inferred_type is 'string', 'unicode' or 'mixed')i   s5   Can only use .str accessor with Index, not MultiIndex(   R\   R  R  s   mixed-integer(   t   pandas.core.indexR   R+   R   R   R   R   R,   R  R'   t   inferred_typeR   (   R  R   t   allowed_typest   inf_typet   message(    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyR    s"    	c         C   sE   t  | t  r4 |  j d | j d | j d | j  S|  j |  Sd  S(   NR   R   R   (   R+   R   R   R   R   R   (   R  t   key(    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyt   __getitem__0  s    %c         c   sP   d } |  j  |  } x4 | j   j   rK | V| d 7} |  j  |  } q Wd  S(   Ni    i   (   R   t   notnat   any(   R  R   R)   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyt   __iter__6  s    
c         C   s  d d l  m } m } m } | rX |  j rX t | | |  j d t j j	 d | } n  t
 | d  sx t
 | d  r| | S| j d k  s t  | d  k r | j d k r t n t } n | t k rlt |  j |  rld	   }	 g  | D] }
 |	 |
  ^ q } | rlt d
   | D  } g  | D]; }
 t |
  d k sP|
 d t j k rZ|
 | n |
 ^ q%} qln  t | t  st d   n  | t k r| d  k rt | d d   } n  | d  k r|  j j } qn  t |  j |  rVt |  r| S| rCt |  } | j | d | } | j d k r?| j d  } n  | S| | d | SnV |  j j } | r|  j j } | | d | d | S|  j j } | | d | d | Sd  S(   Ni(   R   t   SeriesR   R  t
   fill_valuet   ndimR   i   i   c         S   s   t  |   r |  S|  g Sd  S(   N(   R   (   R(   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyt   cons_rowY  s    c         s   s   |  ] } t  |  Vq d  S(   N(   R   (   t   .0R(   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pys	   <genexpr>b  s    i    s   expand must be True or FalseR   R   R   R   (    R   R   R'  R   R  R   R   Re   t   catt   codest   hasattrR)  t   AssertionErrorRc   R!   R+   t   maxR   R   R9   RK   Rd   R   R   R   Ru   R   R   t   get_level_valuesR   R   t   _constructor(   R  R?   t	   use_codesR   R   R(  R   R'  R   R*  R(   t   max_lent   outR   t   cons(    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyR   >  sN    ! 	Kc         C   s  d d l  m } m } m } t |  j |  r7 |  j n	 |  j j } d } t | |  r | j j |  } | r | r | | j d | n | g }	 |	 | f St | |  r | j |  } | | j d | r | n | g }	 |	 | f St | |  rS| j j |  } | r2| r2| j	   } | | _ n  g  | D] }
 | |
 ^ q9| f St | t
 j  r| j d k r| | d | } g  | D] }
 | |
 ^ qt f St | d t rt |  } t d   | D  rUg  }	 t } t } x<| r+| j d  } t | | | f  p8t | t
 j  o8| j d	 k sDt } n  t | | | | t
 j f  sqt |  } n  t | t
 j  r| j d	 k pt | | | f  } | r| j t k pt d
   | D  } | st | |  rt |   n  |  j | d | \ } } |	 | }	 | p%| } qW| rKt j d t d d n  |	 | f St d   | D  r| | d | g t f Sn  t |   d S(   s  
        Auxiliary function for :meth:`str.cat`. Turn potentially mixed input
        into a list of Series (elements without an index must match the length
        of the calling Series/Index).

        Parameters
        ----------
        others : Series, Index, DataFrame, np.ndarray, list-like or list-like
            of objects that are Series, Index or np.ndarray (1-dim)
        ignore_index : boolean, default False
            Determines whether to forcefully align others with index of caller

        Returns
        -------
        tuple : (others transformed into list of Series,
                 boolean whether FutureWarning should be raised)
        i(   R   R'  R   s   others must be Series, Index, DataFrame, np.ndarrary or list-like (either containing only strings or containing only objects of type Series/Index/list-like/np.ndarray)R   i   t
   allow_setsc         s   s!   |  ] } t  | d  t Vq d S(   R7  N(   R   Re   (   R+  R(   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pys	   <genexpr>  s    i    i   c         s   s   |  ] } t  |  Vq d  S(   N(   R   (   R+  R(   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pys	   <genexpr>  s    t   ignore_indexs   list-likes other than Series, Index, or np.ndarray WITHIN another list-like are deprecated and will be removed in a future version.RJ   i   c         s   s   |  ] } t  |  Vq d  S(   N(   R   (   R+  R(   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pys	   <genexpr>  s    N(   R   R   R'  R   R+   R   R   t   equalsR,   R  R   R*   R)  Re   R   Ru   R/   Rx   R!   R   R.   R&   t   _get_series_listRP   RQ   t   FutureWarning(   R  t   othersR8  R   R'  R   t   idxt   err_msgRQ   t   losR(   t	   join_warnt	   depr_warnt   nxtt   no_deept   is_legalt   wnx(    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyR:    sh    '*

!!!	!	!
	
c            s  d d l  m } m } m } t | t j  r= t d   n  | d k rR d } n  t |  j	 |  r | |  j	 d |  j	   n	 |  j	   | d k rt
      t    } | d k r | j   r   |   n0 | d k	 r| j   rt j | |      n  | j    Sy% |  j | d | d k \ } }	 Wn8 t k
 rn| d k r_t d   qot d   n X| d k r|	 rt j d	 t d
 d n  | d k rd n | } t   f d   | D  rQ| | d d d | d k r| n d d t t |   d t d t }   j | d | \   } g  | D] }
 | |
 ^ q8} n  g    g | D] }
 t
 |
  ^ q_} t j g  | D] }
 t |
  ^ q } t j j | d d } | d k r4| j   r4t j t    d t } t j | | t j  | } t g  | D] }
 |
 | ^ q|  | | <np | d k	 r| j   rg  t  | |  D]! \ } } t j | | |  ^ q\} t | |  } n t | |  } t |  j	 |  r| | d t d |  j	 j! } n' | | d t d   j" d |  j	 j! } | S(   sH  
        Concatenate strings in the Series/Index with given separator.

        If `others` is specified, this function concatenates the Series/Index
        and elements of `others` element-wise.
        If `others` is not passed, then all values in the Series/Index are
        concatenated into a single string with a given `sep`.

        Parameters
        ----------
        others : Series, Index, DataFrame, np.ndarrary or list-like
            Series, Index, DataFrame, np.ndarray (one- or two-dimensional) and
            other list-likes of strings must have the same length as the
            calling Series/Index, with the exception of indexed objects (i.e.
            Series/Index/DataFrame) if `join` is not None.

            If others is a list-like that contains a combination of Series,
            Index or np.ndarray (1-dim), then all elements will be unpacked and
            must satisfy the above criteria individually.

            If others is None, the method returns the concatenation of all
            strings in the calling Series/Index.
        sep : str, default ''
            The separator between the different elements/columns. By default
            the empty string `''` is used.
        na_rep : str or None, default None
            Representation that is inserted for all missing values:

            - If `na_rep` is None, and `others` is None, missing values in the
              Series/Index are omitted from the result.
            - If `na_rep` is None, and `others` is not None, a row containing a
              missing value in any of the columns (before concatenation) will
              have a missing value in the result.
        join : {'left', 'right', 'outer', 'inner'}, default None
            Determines the join-style between the calling Series/Index and any
            Series/Index/DataFrame in `others` (objects without an index need
            to match the length of the calling Series/Index). If None,
            alignment is disabled, but this option will be removed in a future
            version of pandas and replaced with a default of `'left'`. To
            disable alignment, use `.values` on any Series/Index/DataFrame in
            `others`.

            .. versionadded:: 0.23.0

        Returns
        -------
        concat : str or Series/Index of objects
            If `others` is None, `str` is returned, otherwise a `Series/Index`
            (same type as caller) of objects is returned.

        See Also
        --------
        split : Split each string in the Series/Index.
        join : Join lists contained as elements in the Series/Index.

        Examples
        --------
        When not passing `others`, all values are concatenated into a single
        string:

        >>> s = pd.Series(['a', 'b', np.nan, 'd'])
        >>> s.str.cat(sep=' ')
        'a b d'

        By default, NA values in the Series are ignored. Using `na_rep`, they
        can be given a representation:

        >>> s.str.cat(sep=' ', na_rep='?')
        'a b ? d'

        If `others` is specified, corresponding values are concatenated with
        the separator. Result will be a Series of strings.

        >>> s.str.cat(['A', 'B', 'C', 'D'], sep=',')
        0    a,A
        1    b,B
        2    NaN
        3    d,D
        dtype: object

        Missing values will remain missing in the result, but can again be
        represented using `na_rep`

        >>> s.str.cat(['A', 'B', 'C', 'D'], sep=',', na_rep='-')
        0    a,A
        1    b,B
        2    -,C
        3    d,D
        dtype: object

        If `sep` is not specified, the values are concatenated without
        separation.

        >>> s.str.cat(['A', 'B', 'C', 'D'], na_rep='-')
        0    aA
        1    bB
        2    -C
        3    dD
        dtype: object

        Series with different indexes can be aligned before concatenation. The
        `join`-keyword works as in other methods.

        >>> t = pd.Series(['d', 'a', 'e', 'c'], index=[3, 0, 4, 2])
        >>> s.str.cat(t, join='left', na_rep='-')
        0    aa
        1    b-
        2    -c
        3    dd
        dtype: object
        >>>
        >>> s.str.cat(t, join='outer', na_rep='-')
        0    aa
        1    b-
        2    -c
        3    dd
        4    -e
        dtype: object
        >>>
        >>> s.str.cat(t, join='inner', na_rep='-')
        0    aa
        2    -c
        3    dd
        dtype: object
        >>>
        >>> s.str.cat(t, join='right', na_rep='-')
        3    dd
        0    aa
        4    -e
        2    -c
        dtype: object

        For more examples, see :ref:`here <text.concatenate>`.
        i(   R   R'  t   concats'   Did you mean to supply a `sep` keyword?R   R   R8  sR   All arrays must be same length, except those having an index if `join` is not Nones   If `others` contains arrays or lists (or other list-likes without an index), these must all be of the same length as the calling Series/Index.s  A future version of pandas will perform index alignment when `others` is a Series/Index/DataFrame (or a list-like containing one). To disable alignment (the behavior before v.0.23) and silence this warning, use `.values` on any Series/Index/DataFrame in `others`. To enable alignment and silence this warning, pass `join='left'|'outer'|'inner'|'right'`. The future default will be `join='left'`.RJ   i   R   c         3   s%   |  ] }   j  j | j   Vq d  S(   N(   R   R9  (   R+  R(   (   R  (    s2   lib/python2.7/site-packages/pandas/core/strings.pys	   <genexpr>  s    R   i   R   t   innert   outerRw   t   sortR  i    R   R   N(#   R   R   R'  RF  R+   R4   R|   Rd   Rc   R   R   R   R%  R   t   whereR   R:  RP   RQ   R;  R   R   Re   t   alignR   t
   logical_ort   reduceR   R.   R:   R9   R   R    R   R   (   R  R<  R   t   na_repR   R   R'  RF  R   RQ   R(   t   all_colst   na_maskst
   union_maskR?   t
   not_maskedt   nmt   col(    (   R  s2   lib/python2.7/site-packages/pandas/core/strings.pyR,    sh    			! &(4!s  
    Split strings around given separator/delimiter.

    Splits the string in the Series/Index from the %(side)s,
    at the specified delimiter string. Equivalent to :meth:`str.%(method)s`.

    Parameters
    ----------
    pat : str, optional
        String or regular expression to split on.
        If not specified, split on whitespace.
    n : int, default -1 (all)
        Limit number of splits in output.
        ``None``, 0 and -1 will be interpreted as return all splits.
    expand : bool, default False
        Expand the splitted strings into separate columns.

        * If ``True``, return DataFrame/MultiIndex expanding dimensionality.
        * If ``False``, return Series/Index, containing lists of strings.

    Returns
    -------
    Series, Index, DataFrame or MultiIndex
        Type matches caller unless ``expand=True`` (see Notes).

    See Also
    --------
     Series.str.split : Split strings around given separator/delimiter.
     Series.str.rsplit : Splits string around given separator/delimiter,
     starting from the right.
     Series.str.join : Join lists contained as elements in the Series/Index
     with passed delimiter.
     str.split : Standard library version for split.
     str.rsplit : Standard library version for rsplit.

    Notes
    -----
    The handling of the `n` keyword depends on the number of found splits:

    - If found splits > `n`,  make first `n` splits only
    - If found splits <= `n`, make all splits
    - If for a certain row the number of found splits < `n`,
      append `None` for padding up to `n` if ``expand=True``

    If using ``expand=True``, Series and Index callers return DataFrame and
    MultiIndex objects, respectively.

    Examples
    --------
    >>> s = pd.Series(["this is a regular sentence",
    "https://docs.python.org/3/tutorial/index.html", np.nan])

    In the default setting, the string is split by whitespace.

    >>> s.str.split()
    0                   [this, is, a, regular, sentence]
    1    [https://docs.python.org/3/tutorial/index.html]
    2                                                NaN
    dtype: object

    Without the `n` parameter, the outputs of `rsplit` and `split`
    are identical.

    >>> s.str.rsplit()
    0                   [this, is, a, regular, sentence]
    1    [https://docs.python.org/3/tutorial/index.html]
    2                                                NaN
    dtype: object

    The `n` parameter can be used to limit the number of splits on the
    delimiter. The outputs of `split` and `rsplit` are different.

    >>> s.str.split(n=2)
    0                     [this, is, a regular sentence]
    1    [https://docs.python.org/3/tutorial/index.html]
    2                                                NaN
    dtype: object

    >>> s.str.rsplit(n=2)
    0                     [this is a, regular, sentence]
    1    [https://docs.python.org/3/tutorial/index.html]
    2                                                NaN
    dtype: object

    The `pat` parameter can be used to split by other characters.

    >>> s.str.split(pat = "/")
    0                         [this is a regular sentence]
    1    [https:, , docs.python.org, 3, tutorial, index...
    2                                                  NaN
    dtype: object

    When using ``expand=True``, the split elements will expand out into
    separate columns. If NaN is present, it is propagated throughout
    the columns during the split.

    >>> s.str.split(expand=True)
                                                   0     1     2        3
    0                                           this    is     a  regular
    1  https://docs.python.org/3/tutorial/index.html  None  None     None
    2                                            NaN   NaN   NaN      NaN 
                 4
    0     sentence
    1         None
    2          NaN

    For slightly more complex use cases like splitting the html document name
    from a url, a combination of parameter settings can be used.

    >>> s.str.rsplit("/", n=1, expand=True)
                                        0           1
    0          this is a regular sentence        None
    1  https://docs.python.org/3/tutorial  index.html
    2                                 NaN         NaN
    R   t	   beginningR   R   R   ic         C   s+   t  |  j | d | } |  j | d | S(   NR`   R   (   R   R   R   (   R  RH   R`   R   R?   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyR   T	  s    R   R   c         C   s+   t  |  j | d | } |  j | d | S(   NR`   R   (   R   R   R   (   R  RH   R`   R   R?   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyR   [	  s    s  
    Split the string at the %(side)s occurrence of `sep`.

    This method splits the string at the %(side)s occurrence of `sep`,
    and returns 3 elements containing the part before the separator,
    the separator itself, and the part after the separator.
    If the separator is not found, return %(return)s.

    Parameters
    ----------
    sep : str, default whitespace
        String to split on.
    pat : str, default whitespace
        .. deprecated:: 0.24.0
           Use ``sep`` instead
    expand : bool, default True
        If True, return DataFrame/MultiIndex expanding dimensionality.
        If False, return Series/Index.

    Returns
    -------
    DataFrame/MultiIndex or Series/Index of objects

    See Also
    --------
    %(also)s
    Series.str.split : Split strings around given separators.
    str.partition : Standard library version.

    Examples
    --------

    >>> s = pd.Series(['Linda van der Berg', 'George Pitt-Rivers'])
    >>> s
    0    Linda van der Berg
    1    George Pitt-Rivers
    dtype: object

    >>> s.str.partition()
            0  1             2
    0   Linda     van der Berg
    1  George      Pitt-Rivers

    To partition by the last space instead of the first one:

    >>> s.str.rpartition()
                   0  1            2
    0  Linda van der            Berg
    1         George     Pitt-Rivers

    To partition by something different than a space:

    >>> s.str.partition('-')
                        0  1       2
    0  Linda van der Berg
    1         George Pitt  -  Rivers

    To return a Series containining tuples instead of a DataFrame:

    >>> s.str.partition('-', expand=False)
    0    (Linda van der Berg, , )
    1    (George Pitt, -, Rivers)
    dtype: object

    Also available on indices:

    >>> idx = pd.Index(['X 123', 'Y 999'])
    >>> idx
    Index(['X 123', 'Y 999'], dtype='object')

    Which will create a MultiIndex:

    >>> idx.str.partition()
    MultiIndex(levels=[['X', 'Y'], [' '], ['123', '999']],
               codes=[[0, 1], [0, 0], [0, 1]])

    Or an index with tuples with ``expand=False``:

    >>> idx.str.partition(expand=False)
    Index([('X', ' ', '123'), ('Y', ' ', '999')], dtype='object')
    t   str_partitiont   firstsF   3 elements containing the string itself, followed by two empty stringst   returns>   rpartition : Split the string at the last occurrence of `sep`.t   alsot   old_arg_nameRH   t   new_arg_nameR   R   c            s4     f d   } t  | |  j  } |  j | d | S(   Nc            s   |  j     S(   N(   t	   partition(   R(   (   R   (    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE   	  s    R   (   R%   R   R   (   R  R   R   R"   R?   (    (   R   s2   lib/python2.7/site-packages/pandas/core/strings.pyR\  	  s    	t   lastsF   3 elements containing two empty strings, followed by the string itselfs>   partition : Split the string at the first occurrence of `sep`.c            s4     f d   } t  | |  j  } |  j | d | S(   Nc            s   |  j     S(   N(   t
   rpartition(   R(   (   R   (    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE   	  s    R   (   R%   R   R   (   R  R   R   R"   R?   (    (   R   s2   lib/python2.7/site-packages/pandas/core/strings.pyR^  	  s    	c         C   s   t  |  j |  } |  j |  S(   N(   R   R   R   (   R  R   R?   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyR   	  s    c         C   s   t  |  j |  } |  j |  S(   N(   R   R   R   (   R  R   R?   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyR   	  s    i    c         C   s=   t  |  j | d | d | d | d | } |  j | d | S(   NRS   RB   RT   RD   R(  (   RV   R   R   (   R  RH   RS   RB   RT   RD   R?   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyt   contains	  s    !	c      	   C   s7   t  |  j | d | d | d | } |  j | d | S(   NRS   RB   RT   R(  (   Rt   R   R   (   R  RH   RS   RB   RT   R?   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyRs   	  s    $c         C   s:   t  |  j | | d | d | d | d | } |  j |  S(   NR`   RS   RB   RD   (   Rg   R   R   (   R  RH   R[   R`   RS   RB   RD   R?   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyRa   	  s    c         C   s   t  |  j |  } |  j |  S(   N(   Rr   R   R   (   R  Rk   R?   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyt   repeat	  s    R   c         C   s+   t  |  j | d | d | } |  j |  S(   NR   R   (   R   R   R   (   R  R   R   R   R?   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyt   pad	  s    s  
    Filling %(side)s side of strings in the Series/Index with an
    additional character. Equivalent to :meth:`str.%(method)s`.

    Parameters
    ----------
    width : int
        Minimum width of resulting string; additional characters will be filled
        with ``fillchar``
    fillchar : str
        Additional character for filling, default is whitespace

    Returns
    -------
    filled : Series/Index of objects
    R   s   left and rightR   c         C   s   |  j  | d d d | S(   NR   R   R   (   Ra  (   R  R   R   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyR   
  s    R   R   c         C   s   |  j  | d d d | S(   NR   R   R   (   Ra  (   R  R   R   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyR   	
  s    R   c         C   s   |  j  | d d d | S(   NR   R   R   (   Ra  (   R  R   R   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyR   
  s    c         C   s+   t  |  j | d d d d } |  j |  S(   s1  
        Pad strings in the Series/Index by prepending '0' characters.

        Strings in the Series/Index are padded with '0' characters on the
        left of the string to reach a total string length  `width`. Strings
        in the Series/Index with length greater or equal to `width` are
        unchanged.

        Parameters
        ----------
        width : int
            Minimum length of resulting string; strings with length less
            than `width` be prepended with '0' characters.

        Returns
        -------
        Series/Index of objects

        See Also
        --------
        Series.str.rjust : Fills the left side of strings with an arbitrary
            character.
        Series.str.ljust : Fills the right side of strings with an arbitrary
            character.
        Series.str.pad : Fills the specified sides of strings with an arbitrary
            character.
        Series.str.center : Fills boths sides of strings with an arbitrary
            character.

        Notes
        -----
        Differs from :meth:`str.zfill` which has special handling
        for '+'/'-' in the string.

        Examples
        --------
        >>> s = pd.Series(['-1', '1', '1000', 10, np.nan])
        >>> s
        0      -1
        1       1
        2    1000
        3      10
        4     NaN
        dtype: object

        Note that ``10`` and ``NaN`` are not strings, therefore they are
        converted to ``NaN``. The minus sign in ``'-1'`` is treated as a
        regular character and the zero is added to the left of it
        (:meth:`str.zfill` would have moved it to the left). ``1000``
        remains unchanged as it is longer than `width`.

        >>> s.str.zfill(3)
        0     0-1
        1     001
        2    1000
        3     NaN
        4     NaN
        dtype: object
        R   R   R   t   0(   R   R   R   (   R  R   R?   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyt   zfill
  s    <c         C   s%   t  |  j | | |  } |  j |  S(   N(   R   R   R   (   R  R   R   R   R?   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyR   P
  s    c         C   s%   t  |  j | | |  } |  j |  S(   N(   R   R   R   (   R  R   R   R[   R?   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyt   slice_replaceU
  s    R   c         C   s"   t  |  j | |  } |  j |  S(   N(   R   R   R   (   R  R   R   R?   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyR   Z
  s    c         C   s"   t  |  j | |  } |  j |  S(   N(   R  R   R   (   R  R   R   R?   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyR  _
  s    sz  
    Remove leading and trailing characters.

    Strip whitespaces (including newlines) or a set of specified characters
    from each string in the Series/Index from %(side)s.
    Equivalent to :meth:`str.%(method)s`.

    Parameters
    ----------
    to_strip : str or None, default None
        Specifying the set of characters to be removed.
        All combinations of this set of characters will be stripped.
        If None then whitespaces are removed.

    Returns
    -------
    Series/Index of objects

    See Also
    --------
    Series.str.strip : Remove leading and trailing characters in Series/Index.
    Series.str.lstrip : Remove leading characters in Series/Index.
    Series.str.rstrip : Remove trailing characters in Series/Index.

    Examples
    --------
    >>> s = pd.Series(['1. Ant.  ', '2. Bee!\n', '3. Cat?\t', np.nan])
    >>> s
    0    1. Ant.
    1    2. Bee!\n
    2    3. Cat?\t
    3          NaN
    dtype: object

    >>> s.str.strip()
    0    1. Ant.
    1    2. Bee!
    2    3. Cat?
    3        NaN
    dtype: object

    >>> s.str.lstrip('123.')
    0    Ant.
    1    Bee!\n
    2    Cat?\t
    3       NaN
    dtype: object

    >>> s.str.rstrip('.!? \n\t')
    0    1. Ant
    1    2. Bee
    2    3. Cat
    3       NaN
    dtype: object

    >>> s.str.strip('123.!? \n\t')
    0    Ant
    1    Bee
    2    Cat
    3    NaN
    dtype: object
    R   s   left and right sidesR   c         C   s%   t  |  j | d d } |  j |  S(   NR   R   (   R   R   R   (   R  R   R?   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyR   
  s    s	   left sideR   c         C   s%   t  |  j | d d } |  j |  S(   NR   R   (   R   R   R   (   R  R   R?   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyR   
  s    s
   right sideR   c         C   s%   t  |  j | d d } |  j |  S(   NR   R   (   R   R   R   (   R  R   R?   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyR   
  s    c         K   s"   t  |  j | |  } |  j |  S(   N(   R   R   R   (   R  R   R   R?   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyR   
  s    R   c         C   s\   |  j  r |  j j t  n |  j } t | |  \ } } |  j | d |  j  d | d t S(   NR3  R   R   (   R  R   R   R   R   R   R   R!   (   R  R   R  R?   R   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyt   get_dummies
  s    $c         C   s"   t  |  j | |  } |  j |  S(   N(   R   R   R   (   R  R   R   R?   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyR   
  s    RB   RT   c         C   s   t  |  | d | d | S(   NRB   R   (   R   (   R  RH   RB   R   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyt   extract
  s    c         C   s   t  |  j | d | S(   NRB   (   R   R   (   R  RH   RB   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyt
   extractall
  s    s  
    Return %(side)s indexes in each strings in the Series/Index
    where the substring is fully contained between [start:end].
    Return -1 on failure. Equivalent to standard :meth:`str.%(method)s`.

    Parameters
    ----------
    sub : str
        Substring being searched
    start : int
        Left edge index
    end : int
        Right edge index

    Returns
    -------
    found : Series/Index of integer values

    See Also
    --------
    %(also)s
    R   t   lowests/   rfind : Return highest indexes in each strings.c      	   C   s1   t  |  j | d | d | d d } |  j |  S(   NR   R   R   R   (   R   R   R   (   R  R^   R   R   R?   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyR   
  s    $t   highestR   s-   find : Return lowest indexes in each strings.c      	   C   s1   t  |  j | d | d | d d } |  j |  S(   NR   R   R   R   (   R   R   R   (   R  R^   R   R   R?   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyR   
  s    c            s=   d d l      f d   } t | |  j  } |  j |  S(   sk  
        Return the Unicode normal form for the strings in the Series/Index.
        For more information on the forms, see the
        :func:`unicodedata.normalize`.

        Parameters
        ----------
        form : {'NFC', 'NFKC', 'NFD', 'NFKD'}
            Unicode form

        Returns
        -------
        normalized : Series/Index of objects
        iNc            s    j    t j |    S(   N(   t	   normalizeR4   t   u_safe(   R(   (   t   formt   unicodedata(    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE     s    (   Rm  R%   R   R   (   R  Rl  R"   R?   (    (   Rl  Rm  s2   lib/python2.7/site-packages/pandas/core/strings.pyRj  
  s    s&  
    Return %(side)s indexes in each strings where the substring is
    fully contained between [start:end]. This is the same as
    ``str.%(similar)s`` except instead of returning -1, it raises a ValueError
    when the substring is not found. Equivalent to standard ``str.%(method)s``.

    Parameters
    ----------
    sub : str
        Substring being searched
    start : int
        Left edge index
    end : int
        Right edge index

    Returns
    -------
    found : Series/Index of objects

    See Also
    --------
    %(also)s
    R   t   similars0   rindex : Return highest indexes in each strings.c      	   C   s1   t  |  j | d | d | d d } |  j |  S(   NR   R   R   R   (   R   R   R   (   R  R^   R   R   R?   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyR   '  s    R   s.   index : Return lowest indexes in each strings.c      	   C   s1   t  |  j | d | d | d d } |  j |  S(   NR   R   R   R   (   R   R   R   (   R  R^   R   R   R?   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyR   /  s    s  
    Computes the length of each element in the Series/Index. The element may be
    a sequence (such as a string, tuple or list) or a collection
    (such as a dictionary).

    Returns
    -------
    Series or Index of int
        A Series or Index of integer values indicating the length of each
        element in the Series or Index.

    See Also
    --------
    str.len : Python built-in function returning the length of an object.
    Series.size : Returns the length of the Series.

    Examples
    --------
    Returns the length (number of characters) in a string. Returns the
    number of entries for dictionaries, lists or tuples.

    >>> s = pd.Series(['dog',
    ...                 '',
    ...                 5,
    ...                 {'foo' : 'bar'},
    ...                 [2, 3, 5, 7],
    ...                 ('one', 'two', 'three')])
    >>> s
    0                  dog
    1
    2                    5
    3       {'foo': 'bar'}
    4         [2, 3, 5, 7]
    5    (one, two, three)
    dtype: object
    >>> s.str.len()
    0    3.0
    1    0.0
    2    NaN
    3    1.0
    4    4.0
    5    3.0
    dtype: float64
    R   R
  R   s\  
    Convert strings in the Series/Index to %(type)s.

    Equivalent to :meth:`str.%(method)s`.

    Returns
    -------
    Series/Index of objects

    See Also
    --------
    Series.str.lower : Converts all characters to lowercase.
    Series.str.upper : Converts all characters to uppercase.
    Series.str.title : Converts first character of each word to uppercase and
        remaining to lowercase.
    Series.str.capitalize : Converts first character to uppercase and
        remaining to lowercase.
    Series.str.swapcase : Converts uppercase to lowercase and lowercase to
        uppercase.

    Examples
    --------
    >>> s = pd.Series(['lower', 'CAPITALS', 'this is a sentence', 'SwApCaSe'])
    >>> s
    0                 lower
    1              CAPITALS
    2    this is a sentence
    3              SwApCaSe
    dtype: object

    >>> s.str.lower()
    0                 lower
    1              capitals
    2    this is a sentence
    3              swapcase
    dtype: object

    >>> s.str.upper()
    0                 LOWER
    1              CAPITALS
    2    THIS IS A SENTENCE
    3              SWAPCASE
    dtype: object

    >>> s.str.title()
    0                 Lower
    1              Capitals
    2    This Is A Sentence
    3              Swapcase
    dtype: object

    >>> s.str.capitalize()
    0                 Lower
    1              Capitals
    2    This is a sentence
    3              Swapcase
    dtype: object

    >>> s.str.swapcase()
    0                 LOWER
    1              capitals
    2    THIS IS A SENTENCE
    3              sWaPcAsE
    dtype: object
    t   casemethodsR   t	   lowercaset   lowert	   uppercaseRM   t	   titlecaset   titles   be capitalizedt
   capitalizes   be swapcasedt   swapcasec         C   s
   |  j    S(   N(   Rq  (   R(   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE     s    c         C   s
   |  j    S(   N(   RM   (   R(   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE     s    c         C   s
   |  j    S(   N(   Rt  (   R(   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE     s    c         C   s
   |  j    S(   N(   Ru  (   R(   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE     s    c         C   s
   |  j    S(   N(   Rv  (   R(   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE     s    s  
    Check whether all characters in each string are %(type)s.

    This is equivalent to running the Python string method
    :meth:`str.%(method)s` for each element of the Series/Index. If a string
    has zero characters, ``False`` is returned for that check.

    Returns
    -------
    Series or Index of bool
        Series or Index of boolean values with the same length as the original
        Series/Index.

    See Also
    --------
    Series.str.isalpha : Check whether all characters are alphabetic.
    Series.str.isnumeric : Check whether all characters are numeric.
    Series.str.isalnum : Check whether all characters are alphanumeric.
    Series.str.isdigit : Check whether all characters are digits.
    Series.str.isdecimal : Check whether all characters are decimal.
    Series.str.isspace : Check whether all characters are whitespace.
    Series.str.islower : Check whether all characters are lowercase.
    Series.str.isupper : Check whether all characters are uppercase.
    Series.str.istitle : Check whether all characters are titlecase.

    Examples
    --------
    **Checks for Alphabetic and Numeric Characters**

    >>> s1 = pd.Series(['one', 'one1', '1', ''])

    >>> s1.str.isalpha()
    0     True
    1    False
    2    False
    3    False
    dtype: bool

    >>> s1.str.isnumeric()
    0    False
    1    False
    2     True
    3    False
    dtype: bool

    >>> s1.str.isalnum()
    0     True
    1     True
    2     True
    3    False
    dtype: bool

    Note that checks against characters mixed with any additional punctuation
    or whitespace will evaluate to false for an alphanumeric check.

    >>> s2 = pd.Series(['A B', '1.5', '3,000'])
    >>> s2.str.isalnum()
    0    False
    1    False
    2    False
    dtype: bool

    **More Detailed Checks for Numeric Characters**

    There are several different but overlapping sets of numeric characters that
    can be checked for.

    >>> s3 = pd.Series(['23', '³', '⅕', ''])

    The ``s3.str.isdecimal`` method checks for characters used to form numbers
    in base 10.

    >>> s3.str.isdecimal()
    0     True
    1    False
    2    False
    3    False
    dtype: bool

    The ``s.str.isdigit`` method is the same as ``s3.str.isdecimal`` but also
    includes special digits, like superscripted and subscripted digits in
    unicode.

    >>> s3.str.isdigit()
    0     True
    1     True
    2    False
    3    False
    dtype: bool

    The ``s.str.isnumeric`` method is the same as ``s3.str.isdigit`` but also
    includes other characters that can represent quantities such as unicode
    fractions.

    >>> s3.str.isnumeric()
    0     True
    1     True
    2     True
    3    False
    dtype: bool

    **Checks for Whitespace**

    >>> s4 = pd.Series([' ', '\t\r\n ', ''])
    >>> s4.str.isspace()
    0     True
    1     True
    2    False
    dtype: bool

    **Checks for Character Case**

    >>> s5 = pd.Series(['leopard', 'Golden Eagle', 'SNAKE', ''])

    >>> s5.str.islower()
    0     True
    1    False
    2    False
    3    False
    dtype: bool

    >>> s5.str.isupper()
    0    False
    1    False
    2     True
    3    False
    dtype: bool

    The ``s5.str.istitle`` method checks for whether all words are in title
    case (whether only the first letter of each word is capitalized). Words are
    assumed to be as any sequence of non-numeric characters seperated by
    whitespace characters.

    >>> s5.str.istitle()
    0    False
    1     True
    2    False
    3    False
    dtype: bool
    t	   ismethodst   alphanumerict   isalnumt
   alphabetict   isalphat   digitst   isdigitt
   whitespacet   isspacet   islowert   isuppert   istitlet   numerict	   isnumerict   decimalt	   isdecimalc         C   s
   |  j    S(   N(   Ry  (   R(   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE   Q  s    c         C   s
   |  j    S(   N(   R{  (   R(   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE   T  s    c         C   s
   |  j    S(   N(   R}  (   R(   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE   W  s    c         C   s
   |  j    S(   N(   R  (   R(   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE   Z  s    c         C   s
   |  j    S(   N(   R  (   R(   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE   ]  s    c         C   s
   |  j    S(   N(   R  (   R(   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE   `  s    c         C   s
   |  j    S(   N(   R  (   R(   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE   c  s    c         C   s   t  j |   j   S(   N(   R4   Rk  R  (   R(   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE   f  s    c         C   s   t  j |   j   S(   N(   R4   Rk  R  (   R(   (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyRE   i  s    c         C   s   |  j  |  |  |  S(   N(   R  (   t   clsR  (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyt   _make_accessorm  s    (a   R   t
   __module__R	  R  t   staticmethodR  R#  R&  R!   Rc   R   R9   R   Re   R:  R,  t   _shared_docsR   R   R   R   R\  R^  R  R   R   R   R   RV   R_  Rt   Rs   Rg   Ra   Rr   R`  R   Ra  R   R   R   R   Rc  R   R   R   Rd  R   R   R  R  R   R   R   R   R   R   Re  R   R   R  RI   R]   RX   RW   RZ   RY   R   RC   R   Rf  R   Rg  R   R   Rj  R   R   R  R   RG   Rq  RM   Rt  Ru  Rv  Ry  R{  R}  R  R  R  R  R  R  t   classmethodR  (    (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyR    sH  
	
#		Pp T
T
				

  	?				A



				




	*




0
B

(   s   utf-8R   s   latin-1R   s
   iso-8859-1R   R   (   s   utf-16s   utf-32(V   R   R7   R   RP   t   numpyR   t   pandas._libs.libt   _libsR0   t   pandas._libs.opst   opsRn   t   pandas.compatR4   R    t   pandas.util._decoratorsR   R   t   pandas.core.dtypes.commonR   R   R   R   R   R   R	   R
   R   t   pandas.core.dtypes.genericR   R   t   pandas.core.dtypes.missingR   t   pandas.core.algorithmsR   t   pandas.core.baseR   t   pandas.core.commont   coret   commonRp   R  R   R   R  R   R9   R.   R%   Re   R    RI   R!   RV   RX   RZ   Rc   Rg   Rr   Rt   R{   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R  R  R  R  R  (    (    (    s2   lib/python2.7/site-packages/pandas/core/strings.pyt   <module>   sn   @		)E77	:#		!\q3	A^(L	G[	?&	;	