I have multiple csv files on which I have to remove 2 rows because they are only NaNs. I want to load the first one, perform the cleaning and then load the second one do the cleaning and concatenate with the first one and so on.
This is the code:
df_result = None
for file in tqdm(files):
df = pd.read_csv(file)
df = clean_csv(df)
df = df.to_numpy()
try:
df_result = pd.concat([df_result,df],axis = 'index',ignore_index=True)
except:
df_result = df
with clean_csv:
def clean_csv(df):
df_1 = df.drop(labels = [0,1])
df_1 = df_1.drop('Start Time', axis = 1)
return df_1