We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 439acc9 commit 411e8baCopy full SHA for 411e8ba
pandas/core/generic.py
@@ -3454,6 +3454,18 @@ def to_csv(
3454
... archive_name='out.csv') # doctest: +SKIP
3455
>>> df.to_csv('out.zip', index=False,
3456
... compression=compression_opts) # doctest: +SKIP
3457
+
3458
+ To write a csv file to a new folder or nested folder you will first
3459
+ need to create it using either Pathlib or os:
3460
3461
+ >>> from pathlib import Path
3462
+ >>> filepath = Path('folder/subfolder/out.csv')
3463
+ >>> filepath.parent.mkdir(parents=True, exist_ok=True)
3464
+ >>> df.to_csv(filepath)
3465
3466
+ >>> import os
3467
+ >>> os.makedirs('folder/subfolder', exist_ok=True)
3468
+ >>> df.to_csv('folder/subfolder/out.csv')
3469
"""
3470
df = self if isinstance(self, ABCDataFrame) else self.to_frame()
3471
0 commit comments