|
5 | 5 | import pytest
|
6 | 6 |
|
7 | 7 | import pandas as pd
|
8 |
| -import pandas._testing as tm |
9 | 8 | from pandas import DataFrame, Index, MultiIndex, Series, bdate_range
|
| 9 | +import pandas._testing as tm |
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
|
@@ -965,9 +965,13 @@ def fn(x):
|
965 | 965 |
|
966 | 966 | def test_apply_function_with_indexing_return_column():
|
967 | 967 | # GH: 7002
|
968 |
| - df = DataFrame({'foo1': ['one', 'two', 'two', 'three', 'one', 'two'], |
969 |
| - 'foo2': np.random.randn(6)}) |
970 |
| - result = df.groupby('foo1', as_index=False).apply(lambda x: x.mean()) |
971 |
| - expected = df.groupby('foo1', as_index=False).mean() |
| 968 | + df = DataFrame( |
| 969 | + { |
| 970 | + "foo1": ["one", "two", "two", "three", "one", "two"], |
| 971 | + "foo2": np.random.randn(6), |
| 972 | + } |
| 973 | + ) |
| 974 | + result = df.groupby("foo1", as_index=False).apply(lambda x: x.mean()) |
| 975 | + expected = df.groupby("foo1", as_index=False).mean() |
972 | 976 | tm.assert_frame_equal(result, expected)
|
973 |
| - assert 'foo1' in result.columns |
| 977 | + assert "foo1" in result.columns |
0 commit comments