I have a dataframe consisting of multiple .csv files. I want to report a value "feed start" based on a value in a column in the dataframes. However, some of the dataframes are missing that column header ["FC.PV [EFT (h)"]
. I just want to skip the members of the dataframe that don't have the header ["FC.PV [EFT (h)"]
.
shorts = ['F:/DASGIP/CSV files/Run Data/' + str(i) + '.csv' for i in files]
ferms = [pd.read_csv(s) for s in shorts]
for i in range(len(files)):
FStartVs = ferms[i][["FC.PV [EFT (h)]"] > 0.0]["EFT (h)"].min()
print "Feed Start C", files[i], "=", FStartVs[i], "EFT (h)"
I remember seeing a simple statement that allows you to skip a column in a dataframe if it is missing, but can't find it. Any help would be greatly appreciated.
Getting rid of the DataFrames
s in ferms
when they don't have ["FC.PV [EFT (h)"]
column? Add this line after then 2nd line.
ferms=[DF for DF in ferms if '["FC.PV [EFT (h)"]' in DF.columns]