I want to filter the date string column before fetching/reading into Python pandas dataframe.
However, there are 4 formats in this date string column. (MM/DD/YYYY, m/DD/YY, MMDDYYYY, DDMMYY)
Date
08/18/2003
7/21/05
6/30/05
08192005
11/2/05
1/3/06
071006
How can I clean the date string column and filter before query them?
sql = '''SELECT * from data WHERE (Date>= '20201230') AND (Date <= '20201231') LIMIT 5;'''
with engine.connect().execution_options(autocommit=True) as conn:
query = conn.execute(text(sql))
df = pd.DataFrame(query.fetchall())
df.columns = query.keys()
Any idea?