I have input data like this.
NAME | PLACE | DATE
A | X | 2020-04-30
B | Y | 2019-04-30
i want to duplicate 5 times and change d
Here is a way to do it:
df_out = df.reindex(df.index.repeat(6))
df_out['DATE'] += pd.Series([pd.DateOffset(years=i)
for i in df_out.groupby('AME').cumcount()],
index=df_out.index)
df_out.reset_index(drop=True)
Output:
AME PLACE DATE
0 A X 2020-04-30
1 A X 2021-04-30
2 A X 2022-04-30
3 A X 2023-04-30
4 A X 2024-04-30
5 A X 2025-04-30
6 B Y 2019-04-30
7 B Y 2020-04-30
8 B Y 2021-04-30
9 B Y 2022-04-30
10 B Y 2023-04-30
11 B Y 2024-04-30