Skip to content

Commit

Permalink
Bugfix in team.explode method. (#22)
Browse files Browse the repository at this point in the history
There was a bug in the .team.explode() method, which cause the function to get caught in an endless loop. This is now fixed.
  • Loading branch information
PhilippVerpoort authored Aug 21, 2024
1 parent 93d018d commit d167a93
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions python/posted/team.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,15 @@ def explode(self,
if isinstance(fields, str) else fields
)
for field in fields:
df = df \
.assign(**{field: lambda df: df[field].apply(
lambda cell: df[field].dropna().unique().tolist()
if pd.isnull(cell) else cell
)}) \
explodable = pd.Series(
index=df.index,
data=len(df)*[df[field].dropna().unique().tolist()],
)
df = (
df
.assign(**{field: df[field].fillna(explodable)})
.explode(field)
)

return df.reset_index(drop=True)

Expand Down

0 comments on commit d167a93

Please sign in to comment.