Write a Pandas program to convert all the string values to upper, lower cases in a given pandas series. Also find the length of the string values.
import pandas as pd
import numpy as np
str_line = pd.Series(['A', 'B', 'c', 'd' 'AaBb', 'CcDd', 'HELLO', None, 'phone', 'charge', 'BOOk'])
print("Original series:")
print(str_line)
print("\nConvert all string values of the said Series to upper case:")
print(str_line.str.upper())
print("\nConvert all string values of the said Series to lower case:")
print(str_line.str.lower())
print("\nLength of the string values of the said Series:")
print(str_line.str.len())
Comments
Leave a comment