|
| 1 | +# -*- coding: utf-8 -*- |
1 | 2 | import numpy as np
|
2 | 3 |
|
3 | 4 | from pandas.compat import zip
|
@@ -2896,12 +2897,144 @@ def rindex(self, sub, start=0, end=None):
|
2896 | 2897 | _shared_docs['swapcase'])
|
2897 | 2898 |
|
2898 | 2899 | _shared_docs['ismethods'] = ("""
|
2899 |
| - Check whether all characters in each string in the Series/Index |
2900 |
| - are %(type)s. Equivalent to :meth:`str.%(method)s`. |
| 2900 | + Check whether all characters in each string are %(type)s. |
| 2901 | +
|
| 2902 | + This is equivalent to running the Python string method |
| 2903 | + :meth:`str.%(method)s` for each element of the Series/Index. If a string |
| 2904 | + has zero characters, ``False`` is returned for that check. |
2901 | 2905 |
|
2902 | 2906 | Returns
|
2903 | 2907 | -------
|
2904 |
| - is : Series/array of boolean values |
| 2908 | + Series or Index of bool |
| 2909 | + Series or Index of boolean values with the same length as the original |
| 2910 | + Series/Index. |
| 2911 | +
|
| 2912 | + See Also |
| 2913 | + -------- |
| 2914 | + Series.str.isalpha : Check whether all characters are alphabetic. |
| 2915 | + Series.str.isnumeric : Check whether all characters are numeric. |
| 2916 | + Series.str.isalnum : Check whether all characters are alphanumeric. |
| 2917 | + Series.str.isdigit : Check whether all characters are digits. |
| 2918 | + Series.str.isdecimal : Check whether all characters are decimal. |
| 2919 | + Series.str.isspace : Check whether all characters are whitespace. |
| 2920 | + Series.str.islower : Check whether all characters are lowercase. |
| 2921 | + Series.str.isupper : Check whether all characters are uppercase. |
| 2922 | + Series.str.istitle : Check whether all characters are titlecase. |
| 2923 | +
|
| 2924 | + Examples |
| 2925 | + -------- |
| 2926 | + **Checks for Alphabetic and Numeric Characters** |
| 2927 | +
|
| 2928 | + >>> s1 = pd.Series(['one', 'one1', '1', '']) |
| 2929 | +
|
| 2930 | + >>> s1.str.isalpha() |
| 2931 | + 0 True |
| 2932 | + 1 False |
| 2933 | + 2 False |
| 2934 | + 3 False |
| 2935 | + dtype: bool |
| 2936 | +
|
| 2937 | + >>> s1.str.isnumeric() |
| 2938 | + 0 False |
| 2939 | + 1 False |
| 2940 | + 2 True |
| 2941 | + 3 False |
| 2942 | + dtype: bool |
| 2943 | +
|
| 2944 | + >>> s1.str.isalnum() |
| 2945 | + 0 True |
| 2946 | + 1 True |
| 2947 | + 2 True |
| 2948 | + 3 False |
| 2949 | + dtype: bool |
| 2950 | +
|
| 2951 | + Note that checks against characters mixed with any additional punctuation |
| 2952 | + or whitespace will evaluate to false for an alphanumeric check. |
| 2953 | +
|
| 2954 | + >>> s2 = pd.Series(['A B', '1.5', '3,000']) |
| 2955 | + >>> s2.str.isalnum() |
| 2956 | + 0 False |
| 2957 | + 1 False |
| 2958 | + 2 False |
| 2959 | + dtype: bool |
| 2960 | +
|
| 2961 | + **More Detailed Checks for Numeric Characters** |
| 2962 | +
|
| 2963 | + There are several different but overlapping sets of numeric characters that |
| 2964 | + can be checked for. |
| 2965 | +
|
| 2966 | + >>> s3 = pd.Series(['23', '³', '⅕', '']) |
| 2967 | +
|
| 2968 | + The ``s3.str.isdecimal`` method checks for characters used to form numbers |
| 2969 | + in base 10. |
| 2970 | +
|
| 2971 | + >>> s3.str.isdecimal() |
| 2972 | + 0 True |
| 2973 | + 1 False |
| 2974 | + 2 False |
| 2975 | + 3 False |
| 2976 | + dtype: bool |
| 2977 | +
|
| 2978 | + The ``s.str.isdigit`` method is the same as ``s3.str.isdecimal`` but also |
| 2979 | + includes special digits, like superscripted and subscripted digits in |
| 2980 | + unicode. |
| 2981 | +
|
| 2982 | + >>> s3.str.isdigit() |
| 2983 | + 0 True |
| 2984 | + 1 True |
| 2985 | + 2 False |
| 2986 | + 3 False |
| 2987 | + dtype: bool |
| 2988 | +
|
| 2989 | + The ``s.str.isnumeric`` method is the same as ``s3.str.isdigit`` but also |
| 2990 | + includes other characters that can represent quantities such as unicode |
| 2991 | + fractions. |
| 2992 | +
|
| 2993 | + >>> s3.str.isnumeric() |
| 2994 | + 0 True |
| 2995 | + 1 True |
| 2996 | + 2 True |
| 2997 | + 3 False |
| 2998 | + dtype: bool |
| 2999 | +
|
| 3000 | + **Checks for Whitespace** |
| 3001 | +
|
| 3002 | + >>> s4 = pd.Series([' ', '\\t\\r\\n ', '']) |
| 3003 | + >>> s4.str.isspace() |
| 3004 | + 0 True |
| 3005 | + 1 True |
| 3006 | + 2 False |
| 3007 | + dtype: bool |
| 3008 | +
|
| 3009 | + **Checks for Character Case** |
| 3010 | +
|
| 3011 | + >>> s5 = pd.Series(['leopard', 'Golden Eagle', 'SNAKE', '']) |
| 3012 | +
|
| 3013 | + >>> s5.str.islower() |
| 3014 | + 0 True |
| 3015 | + 1 False |
| 3016 | + 2 False |
| 3017 | + 3 False |
| 3018 | + dtype: bool |
| 3019 | +
|
| 3020 | + >>> s5.str.isupper() |
| 3021 | + 0 False |
| 3022 | + 1 False |
| 3023 | + 2 True |
| 3024 | + 3 False |
| 3025 | + dtype: bool |
| 3026 | +
|
| 3027 | + The ``s5.str.istitle`` method checks for whether all words are in title |
| 3028 | + case (whether only the first letter of each word is capitalized). Words are |
| 3029 | + assumed to be as any sequence of non-numeric characters seperated by |
| 3030 | + whitespace characters. |
| 3031 | +
|
| 3032 | + >>> s5.str.istitle() |
| 3033 | + 0 False |
| 3034 | + 1 True |
| 3035 | + 2 False |
| 3036 | + 3 False |
| 3037 | + dtype: bool |
2905 | 3038 | """)
|
2906 | 3039 | _shared_docs['isalnum'] = dict(type='alphanumeric', method='isalnum')
|
2907 | 3040 | _shared_docs['isalpha'] = dict(type='alphabetic', method='isalpha')
|
|
0 commit comments