2

I have a dataframe with 2 columns in it as follows,

Street                   City
8188 E PINNACLE CIR      GOLD CANYON
6701 S SOLADO PL         GOLD CANYON
5051 S DUSTY COYOTE TRL  GOLD CANYON

I am trying to solve a problem where I need to convert first letter of each string of these two column to capital letter and rest to lower case. I mean this is how it should be looking like post-conversion.

Now I doing df['col'].str.capitalize but I am seeing this - 8188 e pinnacle cir (one of the street column output)

Street                   City
8188 E Pinnacle Cir      Gold Canyon
6701 S Solado Pl         Gold Canyon
5051 S Dusty Coyote Trl  Gold Canyon

This is bit tricky to me, is there any better solution for it? Please suggest.

kishore
  • 51
  • 4

1 Answers1

2

Use str.title():

df["Street"] = df["Street"].str.title()
df["City"] = df["City"].str.title()
Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360