2. Write a Python Numpy program to switch the original array to Capital letter, lowercase and uppercase.
The output is:
Original Array: ['python', 'numpy', 'pandas']
Expected Answer:
New_capitalized: ['Python' 'Numpy' 'Pandas']
New_lower_case: ['python' 'numpy' 'pandas']
New_Upper_case: ['PYTHON' 'NUMPY' 'PANDAS']
Sample Answer:
import numpy as np x = np.array(['python', 'numpy', 'pandas'], dtype=np.str) print("Original Array:", x) capitalized_case = np.char.capitalize(x) lowered_case = np.char.lower(x) uppered_case = np.char.upper(x) print("\nNew_capitalized: ", capitalized_case) print("New_lower_case: ", lowered_case) print("New_Upper_case: ", uppered_case
More Exercises:
Python String ExercisesMore Numpy Exercises:
Numpy String ExercisesMore Pandas Exercises:
Pandas Series ExercisesMore Tutorials:
Python Installation - Linux (Ubuntu)