Speed up date columns conversion (pandas) from string to datetime
问题 I am working with a large .csv file in python and its date column is 'str'. I am using the following code to convert the records in this column to datetime. df[date_column].fillna('1900-01-01',inplace=True) df[date_column] = df[date_column].apply(lambda x : pd.to_datetime(x, format = datetime_format)) But this seems to be taking quite a long time to execute. Any suggestions on how to handle this is welcomed. Thanks. 回答1: When you read your csv , you can using parse_dates df = pd.read_csv(