Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (19.9k points)

I have an excel file containing a column of 'Usernames' and I want to copy-paste that data into the adjacent column in the same sheet and call it 'Passwords'. All this must be done in a Python program.

1 Answer

0 votes
by (25.1k points)

You can use pandas to read the excel sheet and then copy the column username to a new column called password and then save it with the same name.

You can do it like this:

df = pd.read_excel('testsheet.xlsx')

df['password'] = df['username']

df.to_excel("testsheet.xlsx", index=False)

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...