Series.str.capitalize() used to capitalize the string elements in pandas series. Series is a type of data structure which is used as same as list in python. Series can contain the different types of data as we want to enter in the series like list.
Syntax : Series.str.capitalize()
Returns: Series/Index of objects
To get the link to csv file, click on nba.csv
Code #1 :
We are using the pandas
Series.str.capitalize() method which helps to convert the very first letter of given series in capital and rest all the characters are remain same the a particular string.
As we have explained that only first letter should be capitalize rest of all should be same. As you can see the output given below.
Before 0 avery bradley 1 jae crowder 2 john holland 3 r.j. hunter 4 jonas jerebko Name: Name, dtype: object After 0 Avery bradley 1 Jae crowder 2 John holland 3 R.j. hunter 4 Jonas jerebko Name: Name, dtype: object
Code #2 :
Before 0 boston celtics 1 boston celtics 2 boston celtics 3 boston celtics 4 boston celtics Name: Team, dtype: object After 0 Boston celtics 1 Boston celtics 2 Boston celtics 3 Boston celtics 4 Boston celtics Name: Team, dtype: object
- Python | pandas.map()
- Python | Pandas Series.pow()
- Python | Pandas Series.dt.day
- Python | Pandas dataframe.sub()
- Python | Pandas Series.div()
- Python | Pandas Series.sub()
- Python | Pandas Series.mul()
- Python | Pandas Series.dt.second
- Python | Pandas PeriodIndex.second
- Python | Pandas Timestamp.day
- Python | Pandas Series.lt()
- Python | Pandas Series.sum()
- Python | Pandas Series.abs()
- Python | Pandas Series.add()
- Python | Pandas Series.dt.tz
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.