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,11 @@ 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
+ % {
1807
+ "side" : "left side" ,
1808
+ "method" : "lstrip" ,
1809
+ "position" : "leading"
1810
+ }
1805
1811
)
1806
1812
@forbid_nonstring_types (["bytes" ])
1807
1813
def lstrip (self , to_strip = None ):
@@ -1810,7 +1816,11 @@ def lstrip(self, to_strip=None):
1810
1816
1811
1817
@Appender (
1812
1818
_shared_docs ["str_strip" ]
1813
- % dict (side = "right side" , method = "rstrip" , position = "trailing" )
1819
+ % {
1820
+ "side" : "right side" ,
1821
+ "method" : "rstrip" ,
1822
+ "position" : "trailing"
1823
+ }
1814
1824
)
1815
1825
@forbid_nonstring_types (["bytes" ])
1816
1826
def rstrip (self , to_strip = None ):
@@ -2412,11 +2422,11 @@ def extractall(self, pat, flags=0):
2412
2422
2413
2423
@Appender (
2414
2424
_shared_docs ["find" ]
2415
- % dict (
2416
- side = "lowest" ,
2417
- method = "find" ,
2418
- also = " rfind : Return highest indexes in each strings.",
2419
- )
2425
+ % {
2426
+ " side" : "lowest" ,
2427
+ " method" : "find" ,
2428
+ " also" : " rfind : Return highest indexes in each strings."
2429
+ }
2420
2430
)
2421
2431
@forbid_nonstring_types (["bytes" ])
2422
2432
def find (self , sub , start = 0 , end = None ):
@@ -2429,11 +2439,11 @@ def find(self, sub, start=0, end=None):
2429
2439
2430
2440
@Appender (
2431
2441
_shared_docs ["find" ]
2432
- % dict (
2433
- side = "highest" ,
2434
- method = "rfind" ,
2435
- also = " find : Return lowest indexes in each strings.",
2436
- )
2442
+ % {
2443
+ " side" : "highest" ,
2444
+ " method" : "rfind" ,
2445
+ " also" : " find : Return lowest indexes in each strings."
2446
+ }
2437
2447
)
2438
2448
@forbid_nonstring_types (["bytes" ])
2439
2449
def rfind (self , sub , start = 0 , end = None ):
@@ -2495,12 +2505,12 @@ def normalize(self, form):
2495
2505
2496
2506
@Appender (
2497
2507
_shared_docs ["index" ]
2498
- % dict (
2499
- side = "lowest" ,
2500
- similar = "find" ,
2501
- method = "index" ,
2502
- also = " rindex : Return highest indexes in each strings.",
2503
- )
2508
+ % {
2509
+ " side" : "lowest" ,
2510
+ " similar" : "find" ,
2511
+ " method" : "index" ,
2512
+ " also" : " rindex : Return highest indexes in each strings."
2513
+ }
2504
2514
)
2505
2515
@forbid_nonstring_types (["bytes" ])
2506
2516
def index (self , sub , start = 0 , end = None ):
@@ -2513,12 +2523,12 @@ def index(self, sub, start=0, end=None):
2513
2523
2514
2524
@Appender (
2515
2525
_shared_docs ["index" ]
2516
- % dict (
2517
- side = "highest" ,
2518
- similar = "rfind" ,
2519
- method = "rindex" ,
2520
- also = " index : Return lowest indexes in each strings.",
2521
- )
2526
+ % {
2527
+ " side" : "highest" ,
2528
+ " similar" : "rfind" ,
2529
+ " method" : "rindex" ,
2530
+ " also" : " index : Return lowest indexes in each strings."
2531
+ }
2522
2532
)
2523
2533
@forbid_nonstring_types (["bytes" ])
2524
2534
def rindex (self , sub , start = 0 , end = None ):
@@ -2653,18 +2663,24 @@ def len(self):
2653
2663
# isalpha, isnumeric isalnum isdigit isdecimal isspace islower isupper istitle
2654
2664
# _doc_args holds dict of strings to use in substituting casemethod docs
2655
2665
_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
- )
2666
+ _doc_args ["lower" ] = {"type" : "lowercase" , "method" : "lower" , "version" : "" }
2667
+ _doc_args ["upper" ] = {"type" : "uppercase" , "method" : "upper" , "version" : "" }
2668
+ _doc_args ["title" ] = {"type" : "titlecase" , "method" : "title" , "version" : "" }
2669
+ _doc_args ["capitalize" ] = {
2670
+ "type" : "be capitalized" ,
2671
+ "method" : "capitalize" ,
2672
+ "version" : ""
2673
+ }
2674
+ _doc_args ["swapcase" ] = {
2675
+ "type" : "be swapcased" ,
2676
+ "method" : "swapcase" ,
2677
+ "version" : "" ,
2678
+ }
2679
+ _doc_args ["casefold" ] = {
2680
+ "type" : "be casefolded" ,
2681
+ "method" : "casefold" ,
2682
+ "version" : "\n .. versionadded:: 0.25.0\n " ,
2683
+ }
2668
2684
2669
2685
@Appender (_shared_docs ["casemethods" ] % _doc_args ["lower" ])
2670
2686
@forbid_nonstring_types (["bytes" ])
@@ -2844,15 +2860,15 @@ def casefold(self):
2844
2860
3 False
2845
2861
dtype: bool
2846
2862
"""
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")
2863
+ _doc_args ["isalnum" ] = { " type" : " alphanumeric" , " method" : " isalnum"}
2864
+ _doc_args ["isalpha" ] = { " type" : " alphabetic" , " method" : " isalpha"}
2865
+ _doc_args ["isdigit" ] = { " type" : " digits" , " method" : " isdigit"}
2866
+ _doc_args ["isspace" ] = { " type" : " whitespace" , " method" : " isspace"}
2867
+ _doc_args ["islower" ] = { " type" : " lowercase" , " method" : " islower"}
2868
+ _doc_args ["isupper" ] = { " type" : " uppercase" , " method" : " isupper"}
2869
+ _doc_args ["istitle" ] = { " type" : " titlecase" , " method" : " istitle"}
2870
+ _doc_args ["isnumeric" ] = { " type" : " numeric" , " method" : " isnumeric"}
2871
+ _doc_args ["isdecimal" ] = { " type" : " decimal" , " method" : " isdecimal"}
2856
2872
# force _noarg_wrapper return type with dtype=np.dtype(bool) (GH 29624)
2857
2873
2858
2874
isalnum = _map_and_wrap (
0 commit comments