Skip to content

Commit d341250

Browse files
committed
feedback: return buffer.getvalue() if no path passed in
1 parent 442a254 commit d341250

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

pandas/core/frame.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2391,7 +2391,7 @@ def to_parquet(
23912391
"""
23922392
from pandas.io.parquet import to_parquet
23932393

2394-
to_parquet(
2394+
return to_parquet(
23952395
self,
23962396
path,
23972397
engine,

pandas/io/parquet.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,19 +304,21 @@ def to_parquet(
304304
partition_cols = [partition_cols]
305305
impl = get_engine(engine)
306306

307-
if path is None:
308-
path = io.BytesIO()
307+
path_or_buf = io.BytesIO() if path is None else path
309308

310-
return impl.write(
309+
impl.write(
311310
df,
312-
path,
311+
path_or_buf,
313312
compression=compression,
314313
index=index,
315314
partition_cols=partition_cols,
316315
storage_options=storage_options,
317316
**kwargs,
318317
)
319318

319+
if path is None:
320+
return path_or_buf.getvalue()
321+
320322

321323
def read_parquet(path, engine: str = "auto", columns=None, **kwargs):
322324
"""

0 commit comments

Comments
 (0)