Applying uppercase to a column in pandas dataframe

后端 未结 3 1304
鱼传尺愫
鱼传尺愫 2020-12-09 07:37

I\'m having trouble applying upper case to a column in my DataFrame.

dataframe is df.

1/2 ID is the column head that need to apply

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-09 08:30

    This should work:

    df['1/2 ID'] = map(lambda x: str(x).upper(), df['1/2 ID'])
    

    and should you want all the columns names to be in uppercase format:

    df.columns = map(lambda x: str(x).upper(), df.columns)
    

提交回复
热议问题