if "fold" in data.columns:
del data["fold"]
result = (
dataframe, dataframe_to_list(df_train), dataframe_to_list(df_valid),
dataframe_to_list(df_infer)
)
After Change
if data is not None and "fold" in data.columns:
del data["fold"]
result = (
dataframe,
dataframe_to_list(df_train) if df_train is not None else None,
dataframe_to_list(df_valid) if df_valid is not None else None,
dataframe_to_list(df_infer) if df_infer is not None else None,
)