TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Dipa Mehta
144
12.6k
499.9k
renaming multiple columns
Nov 20 2019 6:01 AM
I would like to rename multiple columns with the same name by appending the number 1 for each duplicate.
This is what I have tried
select_cols = np.asarray([i for i, col in enumerate(fully_merged.columns) if 'stance' in col]) fully_merged.rename(columns={cols:'stance'+str(i) for cols in fully_merged.columns[select_cols] for i in range(1,7)}) # df.rename(columns={col: '' for col in df.columns[idx_filter]}, inplace=True)
Reply
Answers (
1
)
long can an identifier be in Python
how can I create/use a global variable in a function