From 9cbc3e8117d99054945f7b79e50b1f0250221ab6 Mon Sep 17 00:00:00 2001 From: arw2019 Date: Sat, 1 Aug 2020 17:24:59 +0000 Subject: [PATCH 1/4] rebase + add some more details to doc --- pandas/core/frame.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 79627e43d78c2..0e33ad4422e44 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -2199,8 +2199,10 @@ def to_feather(self, path, **kwargs) -> None: Parameters ---------- - path : str - String file path. + path : str or file-like object + If a string, it will be used as Root Directory path. By file-like + object, we refer to objects with a write() method, such as + a file handler (e.g. via builtin open function) or io.BytesIO. **kwargs : Additional keywords passed to :func:`pyarrow.feather.write_feather`. Starting with pyarrow 0.17, this includes the `compression`, From fb37d733366c254e1f77a5db762ba5de28f7a8ff Mon Sep 17 00:00:00 2001 From: arw2019 Date: Wed, 19 Aug 2020 05:13:12 +0000 Subject: [PATCH 2/4] fixed docstring --- pandas/core/frame.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 34c3639742a63..81c91a8f49e19 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -2216,9 +2216,7 @@ def to_feather(self, path, **kwargs) -> None: Parameters ---------- path : str or file-like object - If a string, it will be used as Root Directory path. By file-like - object, we refer to objects with a write() method, such as - a file handler (e.g. via builtin open function) or io.BytesIO. + If a string, it will be used as Root Directory path. **kwargs : Additional keywords passed to :func:`pyarrow.feather.write_feather`. Starting with pyarrow 0.17, this includes the `compression`, From 3b8e068fe787bfd883053ef856f85397d19c638f Mon Sep 17 00:00:00 2001 From: arw2019 Date: Tue, 8 Sep 2020 00:47:46 +0000 Subject: [PATCH 3/4] feedback --- pandas/core/frame.py | 2 +- pandas/io/feather_format.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 76477265fb97f..3f3c77f9fdeb5 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -2216,7 +2216,7 @@ def to_stata( writer.write_file() @deprecate_kwarg(old_arg_name="fname", new_arg_name="path") - def to_feather(self, path, **kwargs) -> None: + def to_feather(self, path: FilePathOrBuffer[AnyStr], **kwargs) -> None: """ Write a DataFrame to the binary Feather format. diff --git a/pandas/io/feather_format.py b/pandas/io/feather_format.py index a98eebe1c6a2a..827194d4e8fae 100644 --- a/pandas/io/feather_format.py +++ b/pandas/io/feather_format.py @@ -8,7 +8,12 @@ from pandas.io.common import get_filepath_or_buffer -def to_feather(df: DataFrame, path, storage_options: StorageOptions = None, **kwargs): +def to_feather( + df: DataFrame, + path: FilePathOrBuffer[AnyStr], + storage_options: StorageOptions = None, + **kwargs, +): """ Write a DataFrame to the binary Feather format. From 9522751a6b44d2c976f8ddb4ad56598ce91d3f02 Mon Sep 17 00:00:00 2001 From: arw2019 Date: Tue, 8 Sep 2020 01:32:27 +0000 Subject: [PATCH 4/4] add import --- pandas/io/feather_format.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandas/io/feather_format.py b/pandas/io/feather_format.py index 827194d4e8fae..ed3cd3cefe96e 100644 --- a/pandas/io/feather_format.py +++ b/pandas/io/feather_format.py @@ -1,6 +1,8 @@ """ feather-format compat """ -from pandas._typing import StorageOptions +from typing import AnyStr + +from pandas._typing import FilePathOrBuffer, StorageOptions from pandas.compat._optional import import_optional_dependency from pandas import DataFrame, Int64Index, RangeIndex