Reputation: 101
I have a Pandas dataframe with 150 rows and columns "A","B","C". I want to create column "D" that must have:
How can I do this?
Upvotes: 2
Views: 68
Reputation: 164783
Assuming your dataframe index is a regular pd.RangeIndex
(i.e. 0, 1, 2, ...
):
df['D'] = df.index // 50 + 1
Upvotes: 3