Reputation: 4636
I have a DataFrame with indexes 1,2,3.
Name
1 Rob
2 Mark
3 Alex
I want to duplicate that index in a new column so it gets like this:
Name Number
1 Rob 1
2 Mark 2
3 Alex 3
Any ideas?
I forgot one important part: those items in the Numbers column should be turned into string
Upvotes: 0
Views: 35
Reputation: 862661
You can try:
df['Number'] = df.index.astype(str)
Name Number
1 Rob 1
2 Mark 2
3 Alex 3
Upvotes: 2