

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Apply uppercase to a column in Pandas dataframe
Example
import pandas as pd # A dataframe df = pd.DataFrame({'Day': ['mon', 'tue', 'wed', 'thu', 'fri'],'Subject': ['Math', 'english', 'science', 'music', 'games']}) df['Day'] = df['Day'].str.upper() print(df)
Output
Running the above code gives us the following result −
Day Subject 0 MON Math 1 TUE english 2 WED science 3 THU music 4 FRI games
Example
# A dataframe df = pd.DataFrame({'Day': ['mon', 'tue', 'wed', 'thu', 'fri'], 'Subject': ['Math', 'english', 'science', 'music', 'games']}) df1=df['Subject'].apply(lambda x: x.upper()) print(df1)
Output
Running the above code gives us the following result −
0 MATH 1 ENGLISH 2 SCIENCE 3 MUSIC 4 GAMES Name: Subject, dtype: object
- Related Questions & Answers
- Apply uppercase to a column in Pandas dataframe in Python
- Apply function to every row in a Pandas DataFrame
- Apply function to every row in a Pandas DataFrame in Python
- How to shift a column in a Pandas DataFrame?
- How to delete a column from Pandas DataFrame
- Python - Add a zero column to Pandas DataFrame
- How to rename column names in a Pandas DataFrame?
- How to delete a column from a Pandas DataFrame?
- How to sort a column of a Pandas DataFrame?
- Merge Pandas DataFrame with a common column
- Adding new column to existing DataFrame in Pandas
- Python - How to select a column from a Pandas DataFrame
- Pandas dataframe capitalize first letter of a column
- Python - Add a prefix to column names in a Pandas DataFrame
- Capitalize first letter of a column in Pandas dataframe
Advertisements