upper method in Pandas
In Pandas, the upper()
method is used to convert string values to uppercase. It is typically applied using the .str
accessor on Series objects (usually string columns in a DataFrame).
Syntax df['column_name'].str.upper()
Example:
Python
import pandas as pd df = pd.DataFrame({ 'name': ['alice', 'Bob', 'ChARlie'] }) df['name_upper'] = df['name'].str.upper() print(df)
The output of the above code is shown below:
