pandas to_parquet: cleaning up an existing directory before writing

Viewed 177

I would like to understand how to write afresh into an existing parquet store.

I am currently writing a pandas dataframe to a parquet directory as follows:

df = pandas.DataFrame({...})
df.to_parquet('/datastore/data1/', engine='pyarrow', partition=['date'])

However, if I read this data back, add a few columns and write it back, it gets written into a new file into the same sub-directories (i.e. /datastore/data1/date1/).

How can I delete the original data before writing into it? (or should I just delete the whole directory structure prior to writing?). I would like to think there is a simpler way of doing this, rather than remembering to call a remove before every to_parquet.

Any suggestions would be helpful. Thanks!

0 Answers
Related