w3resource

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)
Pandas Series: str.title() function

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



Follow us on Facebook and Twitter for latest update.