Pandas Series: str.title() function
Series-str.title() function
The str.title() function is used to convert strings in the Series/Index to titlecase.
The function is equivalent to str.title().
Syntax:
Series.str.title(self)
Returns: Series/Index of objects
Example:
Python-Pandas Code:
import numpy as np
import pandas as pd
s = pd.Series(['long', 'CAPTAIN', 'this is a car', 'FoOtBaLl'])
s
Output:
0 long 1 CAPTAIN 2 this is a car 3 FoOtBaLl dtype: object
Python-Pandas Code:
import numpy as np
import pandas as pd
s = pd.Series(['long', 'CAPTAIN', 'this is a car', 'FoOtBaLl'])
s.str.title()
Output:
0 Long 1 Captain 2 This Is A Car 3 Football dtype: object
Previous: Series-str.swapcase() function
Next: Series-str.upper() function
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/pandas/series/series-str-title.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics