1010 cast ,
1111)
1212
13- from pandas import CategoricalDtype , DataFrame , Series
13+ from pandas import CategoricalDtype , DataFrame , Series , to_datetime
1414from requests import Response , Session
1515from requests .auth import HTTPBasicAuth
1616from tenacity import retry , stop_after_attempt
@@ -137,6 +137,7 @@ def df(
137137 df = DataFrame (rows , columns = columns or None )
138138
139139 data_types : Dict [str , Any ] = {}
140+ time_fields : List [str ] = []
140141 for info in self .meta :
141142 if not pred (info .name ) or df [info .name ].isnull ().all ():
142143 continue
@@ -153,13 +154,17 @@ def df(
153154 EpidataFieldType .epiweek ,
154155 EpidataFieldType .date_or_epiweek ,
155156 ):
156- data_types [info .name ] = "Int64" if disable_date_parsing else "datetime64[ns]"
157+ data_types [info .name ] = "Int64"
158+ time_fields .append (info .name )
157159 elif info .type == EpidataFieldType .float :
158160 data_types [info .name ] = "Float64"
159161 else :
160162 data_types [info .name ] = "string"
161163 if data_types :
162164 df = df .astype (data_types )
165+ if not disable_date_parsing :
166+ for field in time_fields :
167+ df [field ] = to_datetime (df [field ], format = "%Y%m%d" , errors = "ignore" )
163168 return df
164169
165170
0 commit comments