Skip to content

Commit

Permalink
add rename fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dougbrn committed Jul 26, 2024
1 parent 3cd3baa commit 55765d8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/nested_pandas/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ def count_nested(df, nested, by=None, join=True) -> NestedFrame:
if by is None:
field_to_len = df[nested].nest.fields[0]
counts = (
df[nested].nest.to_lists().apply(lambda x: len(x[field_to_len]), axis=1).rename(f"n_{nested}")
df[nested].nest.to_lists().apply(lambda x: len(x[field_to_len]), axis=1) # .rename(f"n_{nested}")
)
counts.name = f"n_{nested}" # update name directly (rename causes issues downstream)
else:
# this may be able to be sped up using tolists() as well
counts = df[nested].apply(lambda x: x[by].value_counts(sort=False))
Expand Down

0 comments on commit 55765d8

Please sign in to comment.