time date in pandas to csv file code example
Example: time date in pandas to csv file
try:
df.to_csv(
path_to_csv + f'\{file_name}_{now.strftime("%Y-%m-%d")}_to_{now.strftime("%H.%M")}.csv',
date_format='%Y-%m-%d %H:%M:%S', encoding='utf-8', index=False)
except OSError as e:
print("Failed to create the file.......")
raise SystemExit(e)