First you need to extract all the columns of interest to you from data , then you can use pandas applymap to apply to_datetime to each element in the selected frame, I suppose you know the index of the columns you want to extract. In the code below, the column names from the third to sixteenth columns are extracted . you can alternatively define a list and add column names to it and use them in place, you may also need to pass the date / time format of DateTime records
import pandas as pd cols_2_extract = data.columns[2:15] data[cols_2_extract] = data[cols_2_extract].applymap(lambda x : pd.to_datetime(x, format = '%d %M %Y'))
source share