-3

I want to rename the column name in the dataframe from : @switchfoot http://twitpic.com/2y1zl - Awww, that's a bummer. You shoulda got David Carr of Third Day to do it. ;D To "Text" but it is not working

column_name = "@switchfoot http://twitpic.com/2y1zl - Awww, that's a bummer. You shoulda got David Carr of Third Day to do it. ;D"
df_3.rename(columns = { column_name : "Text" })

The above line does not rename the column name any ideas that i can rename the column to "Text".

  • This `df_3.rename(columns = { column_name : "Text" }, inplace=True)` will does. – shaik moeed Aug 05 '23 at 11:48
  • try lambda function ```df_3.rename(columns=lambda x: x.replace('column_name',"text"), inplace=True)``` – vegan_meat Aug 05 '23 at 11:59
  • Welcome to SO! If you seek more than suggestions, please read this first: https://stackoverflow.com/help/minimal-reproducible-example. Posting initial data as test helps / Is posting a link to a photo useful? – OCa Aug 05 '23 at 12:19
  • df3.rename(columns = {'@switchfoot http://twitpic.com/2y1zl - Awww, that's a bummer. You shoulda got David Carr of Third Day to do it. ;D':'Text'}) The apostrophe s in that's is creating a problem. – Kulvardhan Singh Rathore Aug 05 '23 at 17:21

0 Answers0