0

I have Pandas DataFrame like this:

data = pd.DataFrame({"car":["mazda", "audi", "audi", "bmw", "mazda"]})

I would like to have all values like for instance: mazda, audi and so on from big letter at the beginning. So I want to have for example not mazda but Mazda, this operation I would like to make on the whole values in "car" Serie.

dingaro
  • 2,156
  • 9
  • 29
  • 3
    With a modicum of effort: [`str.capitalize`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.str.capitalize.html) – roganjosh Dec 27 '19 at 23:52

1 Answers1

1

You can use .str.capitalize(..) [pandas-doc] for that:

data['car'] = data['car'].str.capitalize()

This then gives us:

>>> data
     car
0  Mazda
1   Audi
2   Audi
3    Bmw
4  Mazda
Willem Van Onsem
  • 443,496
  • 30
  • 428
  • 555
  • It works! but If I use column "car" in further plots I still have small letterts at the beginning, why ? – dingaro Dec 28 '19 at 00:07