I would like to use pd.write_csv to write \"filename\" (with headers) if \"filename\" doesn\'t exist, otherwise to append to \"filename\" if it exists. If I simply use co
In Pandas dataframe "to_csv" function, use header=False if csv file exists & append to existing file.
import os hdr = False if os.path.isfile('filename.csv') else True df.to_csv('filename.csv', mode='a', header=hdr)