I had this issue before:
to change the contents do
my_file = app_files.my_file
csv_file = pandas_csv_file
# set bytes needs a string object...
my_file.set_bytes(csv_file.get_bytes().decode())
You may also have to do
csv_file = anvil.BlobMedia('text/csv', pandas_csv_file)
my_file.set_bytes(csv_file.get_bytes().decode())
Though note - when I did this I could no longer open the csv in google sheets for some reason - only in docs. It did download as a CSV as expected…
You can check this has worked by going to the file in your google drive, right clicking → manage versions.
edit: corrections