Skip to content

Commit 41beb4a

Browse files
committed
fix pep8 issues
1 parent ee2c034 commit 41beb4a

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

pandas/tests/groupby/test_transform.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -729,20 +729,22 @@ def interweave(list_obj):
729729
(-1, 'ffill', None), (-1, 'ffill', 1),
730730
(-1, 'bfill', None), (-1, 'bfill', 1)])
731731
def test_pct_change(test_series, shuffle, periods, fill_method, limit):
732-
# Groupby pct change uses an apply if monotonic and a vectorized operation if non-monotonic
732+
# Groupby pct change uses an apply if monotonic
733+
# and a vectorized operation if non-monotonic
733734
# Shuffle parameter tests each
734735
vals = [np.nan, np.nan, 1, 2, 4, 10, np.nan, np.nan]
735736
keys = ['a', 'b']
736-
df = DataFrame({'key': [k for j in list(map(lambda x: [x] * len(vals), keys)) for k in j],
737-
'vals': vals * 2})
737+
key_v = [k for j in list(map(lambda x: [x] * len(vals), keys)) for k in j]
738+
df = DataFrame({'key': key_v, 'vals': vals * 2})
738739
if shuffle:
739740
df = df.reindex(np.random.permutation(len(df))).reset_index(drop=True)
740741

741742
manual_apply = []
742743
for k in keys:
743-
manual_apply.append(Series(df.loc[df.key == k, 'vals'].values).pct_change(periods=periods,
744-
fill_method=fill_method,
745-
limit=limit))
744+
subgroup = Series(df.loc[df.key == k, 'vals'].values)
745+
manual_apply.append(subgroup.pct_change(periods=periods,
746+
fill_method=fill_method,
747+
limit=limit))
746748
exp_vals = pd.concat(manual_apply).reset_index(drop=True)
747749
exp = pd.DataFrame(exp_vals, columns=['_pct_change'])
748750
grp = df.groupby('key')

0 commit comments

Comments
 (0)