Python Forum
Convert 'object' to 'string'
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Convert 'object' to 'string'
#1
I am using a pandas dataframe and creating plots and one of the columns is dtype: object.
I would like to convert these values into strings, how would i go about that?
Thanks in advance.
Reply
#2
df.column_name = df.column_name.astype(str)
or
df['column name'] = df['column name'].astype(str)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Sad ValueError: could not convert string to float badju 0 4,295 Jul-01-2021, 12:13 AM
Last Post: badju
  Indirectlty convert string to float in JSON file WBPYTHON 6 5,831 May-06-2020, 12:09 PM
Last Post: WBPYTHON
  ValueError: could not convert string to float RahulSingh 3 4,119 Apr-09-2020, 02:59 PM
Last Post: dinesh
  convert a list of string+bytes into a list of strings (python 3) pacscaloupsu 4 10,746 Mar-17-2020, 07:21 AM
Last Post: markfilan
  Convert dataframe string column to numeric in Python darpInd 1 2,271 Mar-14-2020, 10:07 AM
Last Post: ndc85430
  ValueError: could not convert string to float: '4 AVENUE' Kudzo 4 5,867 Jan-26-2020, 10:47 PM
Last Post: Kudzo
  TypeError: expected string or bytes-like object twinpiques 1 25,679 May-06-2019, 08:29 PM
Last Post: Yoriz
  ValueError: could not convert the string to float Grin 3 10,186 Jun-14-2018, 08:17 PM
Last Post: killerrex
  Problema with convert image to string karlo123 1 2,748 May-16-2018, 10:44 PM
Last Post: karlo123
  Error: ValueError: could not convert string to float: 'L200 1.6 D/C' Jaarroy 2 6,525 Jan-18-2018, 02:00 PM
Last Post: Jaarroy

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020