5
5
import pytest
6
6
7
7
import pandas as pd
8
- from pandas import DataFrame , Index , MultiIndex , Series , bdate_range
9
8
import pandas ._testing as tm
9
+ from pandas import DataFrame , Index , MultiIndex , Series , bdate_range
10
10
11
11
12
12
def test_apply_issues ():
@@ -65,8 +65,8 @@ def test_apply_trivial():
65
65
66
66
@pytest .mark .xfail (
67
67
reason = "GH#20066; function passed into apply "
68
- "returns a DataFrame with the same index "
69
- "as the one to create GroupBy object."
68
+ "returns a DataFrame with the same index "
69
+ "as the one to create GroupBy object."
70
70
)
71
71
def test_apply_trivial_fail ():
72
72
# GH 20066
@@ -124,14 +124,14 @@ def f(g):
124
124
(DataFrame ({"a" : [1 , 1 , 1 , 2 , 2 , 1 , 1 , 2 ], "b" : range (8 )}), [1 , 2 ]),
125
125
(DataFrame ({"a" : [1 , 2 , 3 , 1 , 2 , 3 ], "two" : [4 , 5 , 6 , 7 , 8 , 9 ]}), [1 , 2 , 3 ]),
126
126
(
127
- DataFrame (
128
- {
129
- "a" : list ("aaabbbcccc" ),
130
- "B" : [3 , 4 , 3 , 6 , 5 , 2 , 1 , 9 , 5 , 4 ],
131
- "C" : [4 , 0 , 2 , 2 , 2 , 7 , 8 , 6 , 2 , 8 ],
132
- }
133
- ),
134
- ["a" , "b" , "c" ],
127
+ DataFrame (
128
+ {
129
+ "a" : list ("aaabbbcccc" ),
130
+ "B" : [3 , 4 , 3 , 6 , 5 , 2 , 1 , 9 , 5 , 4 ],
131
+ "C" : [4 , 0 , 2 , 2 , 2 , 7 , 8 , 6 , 2 , 8 ],
132
+ }
133
+ ),
134
+ ["a" , "b" , "c" ],
135
135
),
136
136
(DataFrame ([[1 , 2 , 3 ], [2 , 2 , 3 ]], columns = ["a" , "b" , "c" ]), [1 , 2 ]),
137
137
],
@@ -155,6 +155,7 @@ def test_group_apply_once_per_group(df, group_names):
155
155
# once per group
156
156
157
157
names = []
158
+
158
159
# cannot parameterize over the functions since they need external
159
160
# `names` to detect side effects
160
161
@@ -683,7 +684,6 @@ def func_with_date(batch):
683
684
684
685
685
686
def test_gb_apply_list_of_unequal_len_arrays ():
686
-
687
687
# GH1738
688
688
df = DataFrame (
689
689
{
@@ -897,12 +897,12 @@ def test_apply_index_has_complex_internals(index):
897
897
(lambda x : set (x .index .to_list ()), [{0 , 1 }, {2 , 3 }]),
898
898
(lambda x : tuple (x .index .to_list ()), [(0 , 1 ), (2 , 3 )]),
899
899
(
900
- lambda x : {n : i for (n , i ) in enumerate (x .index .to_list ())},
901
- [{0 : 0 , 1 : 1 }, {0 : 2 , 1 : 3 }],
900
+ lambda x : {n : i for (n , i ) in enumerate (x .index .to_list ())},
901
+ [{0 : 0 , 1 : 1 }, {0 : 2 , 1 : 3 }],
902
902
),
903
903
(
904
- lambda x : [{n : i } for (n , i ) in enumerate (x .index .to_list ())],
905
- [[{0 : 0 }, {1 : 1 }], [{0 : 2 }, {1 : 3 }]],
904
+ lambda x : [{n : i } for (n , i ) in enumerate (x .index .to_list ())],
905
+ [[{0 : 0 }, {1 : 1 }], [{0 : 2 }, {1 : 3 }]],
906
906
),
907
907
],
908
908
)
0 commit comments