write_csv_atomic
- write_csv_atomic(df: pandas.DataFrame, path: str | Path, **kwargs: Any) None[source]
Writes df to path as a CSV, replacing the previous file in one step.
The CSV is first written to a temporary file next to path and flushed to disk, and then renamed to path. A rename is atomic, so if the system stops in the middle (a power cut), path keeps its previous content instead of a half-written file.
- Parameters:
df (pd.DataFrame) – The data to write.
path (str | Path) – The CSV file to replace.
**kwargs – Passed to DataFrame.to_csv (sep, index, header…).