26
26
27
27
from pandas .core .base import NoNewAttributesMixin
28
28
29
- _shared_docs : Dict [str , str ] = dict ()
29
+ _shared_docs : Dict [str , str ] = {}
30
30
_cpython_optimized_encoders = (
31
31
"utf-8" ,
32
32
"utf8" ,
@@ -1446,17 +1446,17 @@ def pad(self, width, side="left", fillchar=" "):
1446
1446
filled : Series/Index of objects.
1447
1447
"""
1448
1448
1449
- @Appender (_shared_docs ["str_pad" ] % dict ( side = " left and right" , method = " center") )
1449
+ @Appender (_shared_docs ["str_pad" ] % { " side" : " left and right" , " method" : " center"} )
1450
1450
@forbid_nonstring_types (["bytes" ])
1451
1451
def center (self , width , fillchar = " " ):
1452
1452
return self .pad (width , side = "both" , fillchar = fillchar )
1453
1453
1454
- @Appender (_shared_docs ["str_pad" ] % dict ( side = " right" , method = " ljust") )
1454
+ @Appender (_shared_docs ["str_pad" ] % { " side" : " right" , " method" : " ljust"} )
1455
1455
@forbid_nonstring_types (["bytes" ])
1456
1456
def ljust (self , width , fillchar = " " ):
1457
1457
return self .pad (width , side = "right" , fillchar = fillchar )
1458
1458
1459
- @Appender (_shared_docs ["str_pad" ] % dict ( side = " left" , method = " rjust") )
1459
+ @Appender (_shared_docs ["str_pad" ] % { " side" : " left" , " method" : " rjust"} )
1460
1460
@forbid_nonstring_types (["bytes" ])
1461
1461
def rjust (self , width , fillchar = " " ):
1462
1462
return self .pad (width , side = "left" , fillchar = fillchar )
@@ -1790,9 +1790,11 @@ def encode(self, encoding, errors="strict"):
1790
1790
1791
1791
@Appender (
1792
1792
_shared_docs ["str_strip" ]
1793
- % dict (
1794
- side = "left and right sides" , method = "strip" , position = "leading and trailing"
1795
- )
1793
+ % {
1794
+ "side" : "left and right sides" ,
1795
+ "method" : "strip" ,
1796
+ "position" : "leading and trailing" ,
1797
+ }
1796
1798
)
1797
1799
@forbid_nonstring_types (["bytes" ])
1798
1800
def strip (self , to_strip = None ):
@@ -1801,7 +1803,7 @@ def strip(self, to_strip=None):
1801
1803
1802
1804
@Appender (
1803
1805
_shared_docs ["str_strip" ]
1804
- % dict ( side = " left side" , method = " lstrip" , position = " leading")
1806
+ % { " side" : " left side" , " method" : " lstrip" , " position" : " leading"}
1805
1807
)
1806
1808
@forbid_nonstring_types (["bytes" ])
1807
1809
def lstrip (self , to_strip = None ):
@@ -1810,7 +1812,7 @@ def lstrip(self, to_strip=None):
1810
1812
1811
1813
@Appender (
1812
1814
_shared_docs ["str_strip" ]
1813
- % dict ( side = " right side" , method = " rstrip" , position = " trailing")
1815
+ % { " side" : " right side" , " method" : " rstrip" , " position" : " trailing"}
1814
1816
)
1815
1817
@forbid_nonstring_types (["bytes" ])
1816
1818
def rstrip (self , to_strip = None ):
@@ -2412,11 +2414,11 @@ def extractall(self, pat, flags=0):
2412
2414
2413
2415
@Appender (
2414
2416
_shared_docs ["find" ]
2415
- % dict (
2416
- side = "lowest" ,
2417
- method = "find" ,
2418
- also = "rfind : Return highest indexes in each strings." ,
2419
- )
2417
+ % {
2418
+ " side" : "lowest" ,
2419
+ " method" : "find" ,
2420
+ " also" : "rfind : Return highest indexes in each strings." ,
2421
+ }
2420
2422
)
2421
2423
@forbid_nonstring_types (["bytes" ])
2422
2424
def find (self , sub , start = 0 , end = None ):
@@ -2429,11 +2431,11 @@ def find(self, sub, start=0, end=None):
2429
2431
2430
2432
@Appender (
2431
2433
_shared_docs ["find" ]
2432
- % dict (
2433
- side = "highest" ,
2434
- method = "rfind" ,
2435
- also = "find : Return lowest indexes in each strings." ,
2436
- )
2434
+ % {
2435
+ " side" : "highest" ,
2436
+ " method" : "rfind" ,
2437
+ " also" : "find : Return lowest indexes in each strings." ,
2438
+ }
2437
2439
)
2438
2440
@forbid_nonstring_types (["bytes" ])
2439
2441
def rfind (self , sub , start = 0 , end = None ):
@@ -2495,12 +2497,12 @@ def normalize(self, form):
2495
2497
2496
2498
@Appender (
2497
2499
_shared_docs ["index" ]
2498
- % dict (
2499
- side = "lowest" ,
2500
- similar = "find" ,
2501
- method = "index" ,
2502
- also = "rindex : Return highest indexes in each strings." ,
2503
- )
2500
+ % {
2501
+ " side" : "lowest" ,
2502
+ " similar" : "find" ,
2503
+ " method" : "index" ,
2504
+ " also" : "rindex : Return highest indexes in each strings." ,
2505
+ }
2504
2506
)
2505
2507
@forbid_nonstring_types (["bytes" ])
2506
2508
def index (self , sub , start = 0 , end = None ):
@@ -2513,12 +2515,12 @@ def index(self, sub, start=0, end=None):
2513
2515
2514
2516
@Appender (
2515
2517
_shared_docs ["index" ]
2516
- % dict (
2517
- side = "highest" ,
2518
- similar = "rfind" ,
2519
- method = "rindex" ,
2520
- also = "index : Return lowest indexes in each strings." ,
2521
- )
2518
+ % {
2519
+ " side" : "highest" ,
2520
+ " similar" : "rfind" ,
2521
+ " method" : "rindex" ,
2522
+ " also" : "index : Return lowest indexes in each strings." ,
2523
+ }
2522
2524
)
2523
2525
@forbid_nonstring_types (["bytes" ])
2524
2526
def rindex (self , sub , start = 0 , end = None ):
@@ -2653,18 +2655,24 @@ def len(self):
2653
2655
# isalpha, isnumeric isalnum isdigit isdecimal isspace islower isupper istitle
2654
2656
# _doc_args holds dict of strings to use in substituting casemethod docs
2655
2657
_doc_args : Dict [str , Dict [str , str ]] = {}
2656
- _doc_args ["lower" ] = dict (type = "lowercase" , method = "lower" , version = "" )
2657
- _doc_args ["upper" ] = dict (type = "uppercase" , method = "upper" , version = "" )
2658
- _doc_args ["title" ] = dict (type = "titlecase" , method = "title" , version = "" )
2659
- _doc_args ["capitalize" ] = dict (
2660
- type = "be capitalized" , method = "capitalize" , version = ""
2661
- )
2662
- _doc_args ["swapcase" ] = dict (type = "be swapcased" , method = "swapcase" , version = "" )
2663
- _doc_args ["casefold" ] = dict (
2664
- type = "be casefolded" ,
2665
- method = "casefold" ,
2666
- version = "\n .. versionadded:: 0.25.0\n " ,
2667
- )
2658
+ _doc_args ["lower" ] = {"type" : "lowercase" , "method" : "lower" , "version" : "" }
2659
+ _doc_args ["upper" ] = {"type" : "uppercase" , "method" : "upper" , "version" : "" }
2660
+ _doc_args ["title" ] = {"type" : "titlecase" , "method" : "title" , "version" : "" }
2661
+ _doc_args ["capitalize" ] = {
2662
+ "type" : "be capitalized" ,
2663
+ "method" : "capitalize" ,
2664
+ "version" : "" ,
2665
+ }
2666
+ _doc_args ["swapcase" ] = {
2667
+ "type" : "be swapcased" ,
2668
+ "method" : "swapcase" ,
2669
+ "version" : "" ,
2670
+ }
2671
+ _doc_args ["casefold" ] = {
2672
+ "type" : "be casefolded" ,
2673
+ "method" : "casefold" ,
2674
+ "version" : "\n .. versionadded:: 0.25.0\n " ,
2675
+ }
2668
2676
2669
2677
@Appender (_shared_docs ["casemethods" ] % _doc_args ["lower" ])
2670
2678
@forbid_nonstring_types (["bytes" ])
@@ -2844,15 +2852,15 @@ def casefold(self):
2844
2852
3 False
2845
2853
dtype: bool
2846
2854
"""
2847
- _doc_args ["isalnum" ] = dict ( type = " alphanumeric" , method = " isalnum")
2848
- _doc_args ["isalpha" ] = dict ( type = " alphabetic" , method = " isalpha")
2849
- _doc_args ["isdigit" ] = dict ( type = " digits" , method = " isdigit")
2850
- _doc_args ["isspace" ] = dict ( type = " whitespace" , method = " isspace")
2851
- _doc_args ["islower" ] = dict ( type = " lowercase" , method = " islower")
2852
- _doc_args ["isupper" ] = dict ( type = " uppercase" , method = " isupper")
2853
- _doc_args ["istitle" ] = dict ( type = " titlecase" , method = " istitle")
2854
- _doc_args ["isnumeric" ] = dict ( type = " numeric" , method = " isnumeric")
2855
- _doc_args ["isdecimal" ] = dict ( type = " decimal" , method = " isdecimal")
2855
+ _doc_args ["isalnum" ] = { " type" : " alphanumeric" , " method" : " isalnum"}
2856
+ _doc_args ["isalpha" ] = { " type" : " alphabetic" , " method" : " isalpha"}
2857
+ _doc_args ["isdigit" ] = { " type" : " digits" , " method" : " isdigit"}
2858
+ _doc_args ["isspace" ] = { " type" : " whitespace" , " method" : " isspace"}
2859
+ _doc_args ["islower" ] = { " type" : " lowercase" , " method" : " islower"}
2860
+ _doc_args ["isupper" ] = { " type" : " uppercase" , " method" : " isupper"}
2861
+ _doc_args ["istitle" ] = { " type" : " titlecase" , " method" : " istitle"}
2862
+ _doc_args ["isnumeric" ] = { " type" : " numeric" , " method" : " isnumeric"}
2863
+ _doc_args ["isdecimal" ] = { " type" : " decimal" , " method" : " isdecimal"}
2856
2864
# force _noarg_wrapper return type with dtype=np.dtype(bool) (GH 29624)
2857
2865
2858
2866
isalnum = _map_and_wrap (
0 commit comments