I've got a dataframe called base_varlist2
that has some date columns, all as a string in varying formats. Here's a quick snapshot of the first column:
In [27]: print(base_varlist2.iloc[0])
completion_date_latest 07/10/2004
completion_date_original 17/05/1996
customer_birth_date_1 04/02/1963
customer_birth_date_2 NaN
d_start 01Feb2018
latest_maturity_date 01/03/2027
latest_valuation_date 08/05/2004
sdate NaN
startdt_def NaN
As you can see, some of these columns are empty, some aren't.
I need a way of dynamically changing these to datetime values, regardless of their existing string format. Is there a way to do this from the dataframe, without specifying a specific format for each column? For example, I won't always know if d_start
will be in %d%b%Y
format.
The dataframe was made from the original CSV which is much larger, and contains lots of other columns (that aren't dates), like text fields and numeric fields. I'm using a read_csv
method to bring that in, as below:
source_data = pd.read_csv(loc + 'TEST_FILE.csv')