How do I apply ast.literal_eval to an entire dataframe

Viewed 21

The only way I know to apply ast.literal_eval to an entire dataframe is to loop over each column like so:

for col in df.columns:
         df[col] = df[col].apply(ast.literal_eval)

Is there a more efficient way to do so like using multiprocessing.Pool or some other way?

0 Answers
Related