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
- Import pandas library as pd.
- Create a dataframe using pd.DataFrame().
- Convert all the string values in the DataFrame to uppercases using df.str.upper().
- 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