w3resource

Pandas Series: str.upper() function

Series-str.upper() function

The str.upper() function is used to convert strings in the Series/Index to uppercase.
Equivalent to str.upper().

Syntax:

Series.str.upper(self)
Pandas Series: str.upper() 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.upper()

Output:

0             LONG
1          CAPTAIN
2    THIS IS A CAR
3         FOOTBALL
dtype: object

Previous: Series-str.title() function
Next: Series-str.wrap() function



Follow us on Facebook and Twitter for latest update.