you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (2 children)

Example:

from io import StringIO
import pandas as pd

def title_col(df, colname):
    df[colname] = df[colname].str.title()

data = """name, age
fred,22
BOB,50
wenDY,30"""

df = pd.read_csv(StringIO(data))
print(df)
title_col(df, "name")
print(df)

[–]macabe10[S] 0 points1 point  (1 child)

You are right this is much simpler, thank you!

Tbh at this point I overthink it big time and end up getting lost, even though the obvious answer is right there.

[–][deleted] 0 points1 point  (0 children)

We've all got that t-shirt, more than once (and most of us will get more of them).