MCPcopy
hub / github.com/pandas-dev/pandas / test_apply_iteration

Function test_apply_iteration

pandas/tests/resample/test_time_grouper.py:65–82  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

63
64
65def test_apply_iteration():
66 # #2300
67 N = 1000
68 ind = date_range(start="2000-01-01", freq="D", periods=N)
69 df = DataFrame({"open": 1, "close": 2}, index=ind)
70 tg = Grouper(freq="ME")
71
72 grouper, _ = tg._get_grouper(df)
73
74 # Errors
75 grouped = df.groupby(grouper, group_keys=False)
76
77 def f(df):
78 return df["close"] / df["open"]
79
80 # it works!
81 result = grouped.apply(f)
82 tm.assert_index_equal(result.index, df.index)
83
84
85@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 6

_get_grouperMethod · 0.95
groupbyMethod · 0.95
date_rangeFunction · 0.90
DataFrameClass · 0.90
GrouperClass · 0.90
applyMethod · 0.45

Tested by

no test coverage detected