熊猫中的新列,基于值的增量

时间:2021-03-16 15:29:29

标签: python-3.x dataframe

我想在熊猫中创建一个新列,如果标题列与前一行相同,则顺序是递增的。如果标题不同,重新开始计数。

我该怎么做?

original_df
title
music
music
theatre
theatre
theatre

update_df
order     title
1         music
2         music
1         theatre
2         theatre
3         theatre

0 个答案:

没有答案