File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -3454,6 +3454,18 @@ def to_csv(
3454
3454
... archive_name='out.csv') # doctest: +SKIP
3455
3455
>>> df.to_csv('out.zip', index=False,
3456
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')
3457
3469
"""
3458
3470
df = self if isinstance (self , ABCDataFrame ) else self .to_frame ()
3459
3471
You can’t perform that action at this time.
0 commit comments