I'm working on script that automatically generates full file path column using df.apply() as below.
def generate_filepath(row):
    all_files = os.listdir(files_dir)
    if row['FileName'] not in all_files:
        return None
    value = os.path.join(files_dir, row['FileName'])
    return value
csv_df['FilePath'] = csv_df.apply(generate_filepath, axis=1)
I had to declare files_dir as a global variable and then use it in the function. Is there any other I can pass it as an argument along with df.apply? Kindly help me with good suggestions
 
    