0

I have a dataset with an 'id' column that needs to be converted to String. I have tried all the available options to convert it to String, but it still comes out Object. (I can't provide a sample DataFrame, as my dataset is quite big and the problem goes away in the sample DataFrame.)

I have tried all the following commands:

df['id'] = df['id'].astype(str)
df['id'] = df['id'].values.astype(str)
df['id'] = df['id'].apply(str)
df['id'] = df['id'].map(str)
df['id'] = df['id'].apply(lambda x: str(x))
pd.Series(df['id'], dtype = "string")

I would appreciate any helpful leads.

Abir
  • 57
  • 5
  • *[`object` dtype](https://pandas.pydata.org/docs/user_guide/basics.html#dtypes), can hold any Python object, including strings* – Abdul Niyas P M Jan 10 '23 at 08:12

0 Answers0