pandas groupby-apply behavior, returning a Series (inconsistent output type)

后端 未结 2 589
隐瞒了意图╮
隐瞒了意图╮ 2021-02-05 09:39

I\'m curious about the behavior of pandas groupby-apply when the apply function returns a series.

When the series are of different lengths, it returns a multi-indexed se

2条回答
  •  旧巷少年郎
    2021-02-05 10:27

    instead of doing index=range(len(x)) in your function f, you can do index=x.index to prevent this undesired behavior

提交回复
热议问题