Convert all the string values in the DataFrame to uppercases

In this python pandas program, we will convert all the string values in the DataFrame to uppercases using the pandas library.

Steps to solve the program
  1. Import pandas library as pd.
  2. Create a dataframe using pd.DataFrame().
  3. Convert all the string values in the DataFrame to uppercases using df.str.upper().
  4. Print the output.
				
					import pandas as pd
df = pd.Series(['Cricket','Yes','Pass','Fail'])
print(df)
print("Convert all string values of the Series to upper case:")
print(df.str.upper())
				
			

Output :

				
					0    Cricket
1        Yes
2       Pass
3       Fail
dtype: object
Convert all string values of the Series to upper case:
0    CRICKET
1        YES
2       PASS
3       FAIL
dtype: object
				
			

check whether only the upper case is present in a column of a DataFrame

Leave a Comment