I followed the following procedure: In Python, how do I convert all of the items in a list to floats? because each column of my Dataframe is list
, but instead o
You can use this:
df = df.astype(str)
out of curiosity I decided to see if there is any difference in efficiency between the accepted solution and mine.
The results are below:
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
It seems df.astype
is quite a lot faster :)