File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -708,11 +708,22 @@ def _get_credentials_file():
708
708
709
709
710
710
def _parse_data (schema , rows ):
711
+ # see:
712
+ # http://pandas.pydata.org/pandas-docs/dev/missing_data.html
713
+ # #missing-data-casting-rules-and-indexing
714
+ dtype_map = {'FLOAT' : np .dtype (float ),
715
+ 'TIMESTAMP' : 'M8[ns]' }
711
716
712
717
fields = schema ['fields' ]
713
- col_names = [str (field ['name' ]) for field in fields ]
714
718
715
- df = DataFrame (data = (iter (r ) for r in rows ), columns = col_names )
719
+ column_dtypes = {
720
+ str (field ['name' ]):
721
+ dtype_map .get (field ['type' ].upper (), object ) for field in fields
722
+ }
723
+
724
+ df = DataFrame (data = (iter (r ) for r in rows ), columns = column_dtypes .keys ())
725
+ for column in df :
726
+ df [column ] = df [column ].astype (column_dtypes [column ])
716
727
return df
717
728
718
729
You can’t perform that action at this time.
0 commit comments