23
23
(pd .Series , ([0 , 0 ],), operator .methodcaller ("drop_duplicates" )),
24
24
(pd .Series , ([0 , 0 ],), operator .methodcaller ("duplicated" )),
25
25
(pd .Series , ([0 , 0 ],), operator .methodcaller ("round" )),
26
+ (pd .Series , ([0 , 0 ],), operator .methodcaller ("rename" , lambda x : x + 1 )),
27
+ (pd .Series , ([0 , 0 ],), operator .methodcaller ("rename" , "name" )),
28
+ (pd .Series , ([0 , 0 ],), operator .methodcaller ("set_axis" , ["a" , "b" ])),
29
+ (pd .Series , ([0 , 0 ],), operator .methodcaller ("reindex" , [1 , 0 ])),
30
+ (pd .Series , ([0 , 0 ],), operator .methodcaller ("drop" , [0 ])),
31
+ (pd .Series , (pd .array ([0 , pd .NA ]),), operator .methodcaller ("fillna" , 0 )),
32
+ (pd .Series , ([0 , 0 ],), operator .methodcaller ("replace" , {0 : 1 })),
33
+ (pd .Series , ([0 , 0 ],), operator .methodcaller ("shift" )),
34
+ (pd .Series , ([0 , 0 ],), operator .methodcaller ("isin" , [0 , 1 ])),
35
+ (pd .Series , ([0 , 0 ],), operator .methodcaller ("between" , 0 , 2 )),
36
+ (pd .Series , ([0 , 0 ],), operator .methodcaller ("isna" )),
37
+ (pd .Series , ([0 , 0 ],), operator .methodcaller ("isnull" )),
38
+ (pd .Series , ([0 , 0 ],), operator .methodcaller ("notna" )),
39
+ (pd .Series , ([0 , 0 ],), operator .methodcaller ("notnull" )),
40
+ (
41
+ pd .Series ,
42
+ ([0 ], pd .period_range ("2000" , periods = 1 )),
43
+ operator .methodcaller ("to_timestamp" ),
44
+ ),
45
+ (
46
+ pd .Series ,
47
+ ([0 ], pd .date_range ("2000" , periods = 1 )),
48
+ operator .methodcaller ("to_period" ),
49
+ ),
26
50
]
27
51
28
52
@@ -34,6 +58,31 @@ def ndframe_method(request):
34
58
return request .param
35
59
36
60
61
+ @pytest .mark .parametrize (
62
+ "method" ,
63
+ [
64
+ operator .methodcaller ("upper" ),
65
+ pytest .param (
66
+ operator .methodcaller ("extract" , r"(\w)(\d)" ),
67
+ marks = pytest .mark .xfail (reason = "finalize not called." ),
68
+ ),
69
+ ],
70
+ )
71
+ def test_string_method (method ):
72
+ s = pd .Series (["a1" ])
73
+ s .attrs = {"a" : 1 }
74
+ result = method (s .str )
75
+ assert result .attrs == {"a" : 1 }
76
+
77
+
78
+ @pytest .mark .xfail (reason = "TODO" )
79
+ def test_datetime_method ():
80
+ s = pd .Series (pd .date_range ("2000" , periods = 4 ))
81
+ s .attrs = {"a" : 1 }
82
+ result = s .dt .date
83
+ assert result .attrs == {"a" : 1 }
84
+
85
+
37
86
def test_finalize_called (ndframe_method ):
38
87
cls , init_args , method = ndframe_method
39
88
ndframe = cls (* init_args )
0 commit comments