Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

255
Views
How to make particular column values as upper case?

If I have a dataframe like

a     b     c

bob   ram   sam
john  hp    hcl

Now how do I make a and b column values as uppercase

For single column

df['a'] = df['a'].str.upper()

For all columns

df = df.applymap(lambda s:s.upper() if type(s) == str else s)

or

df.apply(lambda x: x.str.lower() if(x.dtype == 'object') else x)

Expected output

a     b  

BOB   RAM
JOHN  HP  

How do we do it for two columns at once? Like we could do the single column one twice but looking for how to do for both columns.

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Use:

df[['a','b']] = df[['a','b']].applymap(lambda s: s.upper() if isinstance(s, str) else s)

Output:

      a    b    c
0   BOB  RAM  sam
1  JOHN   HP  hcl
over 4 years ago · Santiago Trujillo Report

0

You can do as follow by filter the columns:

df[['a', 'b']] = df[['a', 'b']].applymap(lambda s:s.upper())

Output:

      a    b    c
0   BOB  RAM  sam
1  JOHN   HP  hcl
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!