File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change 66 branches : [ dev ]
77 pull_request :
88 branches : [ dev ]
9+ workflow_dispatch :
910
1011jobs :
1112 unit_tests :
Original file line number Diff line number Diff line change 4141import json
4242import datetime
4343import csv
44+ import pandas as pd
4445from warnings import warn
4546from copy import deepcopy
4647import re
4748from io import StringIO , BytesIO
48- import pandas as pd
4949import requests
5050import numpy as np
5151from zipfile import ZipFile
@@ -972,8 +972,8 @@ def read_trt_data(fname):
972972
973973 Returns
974974 -------
975- A dict containing the read values in a list for every key. Lists are empty
976- if trt file could not be read .
975+ A dict containing the read values in a numpy array for every key. If the file could
976+ not be read only None will be returned .
977977
978978 """
979979 try :
@@ -986,6 +986,20 @@ def read_trt_data(fname):
986986 dict_trt = {key : [] for key in all_trt_keys }
987987 for key in all_trt_keys :
988988 dict_trt [key ].append (feat ["properties" ][key ])
989+
990+ # Use pandas to map string to float/int
991+ df = pd .DataFrame (dict_trt )
992+ for col in df .columns :
993+ try :
994+ df [col ] = pd .to_numeric (df [col ])
995+ except ValueError :
996+ continue
997+
998+ # convert back to dict
999+ dict_trt = df .to_dict (orient = "list" )
1000+ for key in dict_trt :
1001+ dict_trt [key ] = np .array (dict_trt [key ])
1002+
9891003 return dict_trt
9901004
9911005 except EnvironmentError as ee :
You can’t perform that action at this time.
0 commit comments