Skip to content

Commit 5f4e142

Browse files
committed
add handling for full null quality control flags
* in the event that a quality control flag is found in the file header but all values are null- avoid KeyError
1 parent 7b77553 commit 5f4e142

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

fluxdataqaqc/data.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,6 +1363,20 @@ def calc_weight_avg(d, pref, df):
13631363
self.variables.pop(k, None)
13641364
self.units.pop(k, None)
13651365

1366+
# check qc flags to see if they are all null (and drop)
1367+
del_qc_keys = []
1368+
for k,v in self.qc_var_pairs.items():
1369+
if v not in df.columns:
1370+
del_qc_keys.append(k)
1371+
elif df[v].isnull().all():
1372+
print(
1373+
'WARNING: {} variable in column {} is missing all data '
1374+
'it will be removed'.format(k, v)
1375+
)
1376+
del_qc_keys.append(k)
1377+
for k in del_qc_keys:
1378+
self.qc_var_pairs.pop(k, None)
1379+
13661380
# update renaming dict with any newly created mean variables/removed
13671381
self.inv_map = {
13681382
v: k for k, v in self.variables.items() if not k == v

0 commit comments

Comments
 (0)