You can use this:
df = df.astype(str)
Out of curiosity, I decided to see if there is a difference in efficiency between the decision made and mine.
The following are the results:
Example df: df = pd.DataFrame ([list (range (1000))], index = [0])
test df.astype
:
%timeit df.astype(str) >> 100 loops, best of 3: 2.18 ms per loop
test df.applymap
:
%timeit df.applymap(str) 1 loops, best of 3: 245 ms per loop
df.astype
run much faster :)
source share