0
*Input:*
df["waiting_time"].value_counts()
​
*Output:*
2 days      6724
4 days      5290
1 days      5213
7 days      4906
6 days      4037
            ... 
132 days       1
125 days       1
117 days       1
146 days       1
123 days       1
Name: waiting_time, Length: 128, dtype: int64

I tried:

df['wait_dur'] = df['waiting_time'].values.astype(str)

and I've tried apply as well. No changes to the data type, it stays the same.

2 Answers2

2

You need to skip the 'values' part in your code:

    df['wait_dur'] = df['waiting_time'].astype(str)

If you check first row for example, you will get:

    type(df['wait_dur'][0])
    <class 'str'>
Eddson
  • 64
  • 6
0
df = df.applymap(str)

This should work, it applies the map string throughout.

If you want to see more methods go here.

DialFrost
  • 1,610
  • 1
  • 8
  • 28