Pandas Series: str.capitalize() function
Series-str.capitalize() function
The str.capitalize() function is used to convert strings in the Series/Index to be capitalized.
The method is equivalent to str.capitalize().
Series.str.capitalize(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 my car', 'FoOtBaLl'])
s
Output:
0 long 1 CAPTAIN 2 this is my car 3 FoOtBaLl dtype: object
Python-Pandas Code:
import numpy as np
import pandas as pd
s = pd.Series(['long', 'CAPTAIN', 'this is my car', 'FoOtBaLl'])
s.str.capitalize()
Output:
0 Long 1 Captain 2 This is my car 3 Football dtype: object
Previous: Series-dt.total_seconds() function
Next: Series-str.casefold() 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-capitalize.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics