How Does Parse_dates Work With Pd.read_sql_query
How is Pandas parse_date supposed to work when retrieving data from a MySQL database? The documentation of Pandas 0.23 gives this information: parse_dates : list or dict, default:
Solution 1:
I pass the field names in a list to parse_dates when I invoke pd.read_sql with:
df= pd.read_sql(query,
connection,
parse_dates=['Date_of_creation',
'Date_of_termination']
)
You mentioned doing it with a dictionary for custom formatting:
fmt='%Y%m%d %H:%M:%S'
df= pd.read_sql(query,
connection,
parse_dates={'Date_of_creation':fmt,
'Date_of_termination':fmt}
)
Post a Comment for "How Does Parse_dates Work With Pd.read_sql_query"