Have you ever feel a need to change the format of the string like while working with names then we need to change the lower case letters to upper case or vice versa. So for this there are predefined functions are available in python.
This python source code does the following :
1. Creates a pandas series
2. Converts strings into lower and upper format
3. performs splits and capitalization
So this is the recipe on how we can format string in a Pandas DataFrame Column.
import pandas as pd
We have imported one library that is pandas which is only need for this.
We have created a list of names as a data on which we will be doing all the formatting.
first_names = pd.Series(['Sheldon Cooper', 'Leonard Hofstadter', 'Howard Wolowitz', 'Raj Koothrappali'])
So we will be doing different types of formating
0 Sheldon Cooper 1 Leonard Hofstadter 2 Howard Wolowitz 3 Raj Koothrappali dtype: object 0 sheldon cooper 1 leonard hofstadter 2 howard wolowitz 3 raj koothrappali dtype: object 0 SHELDON COOPER 1 LEONARD HOFSTADTER 2 HOWARD WOLOWITZ 3 RAJ KOOTHRAPPALI dtype: object 0 Sheldon Cooper 1 Leonard Hofstadter 2 Howard Wolowitz 3 Raj Koothrappali dtype: object 0 [Sheldon, Cooper] 1 [Leonard, Hofstadter] 2 [Howard, Wolowitz] 3 [Raj, Koothrappali] dtype: object 0 Sheldon cooper 1 Leonard hofstadter 2 Howard wolowitz 3 Raj koothrappali dtype: object