You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "zhengruifeng (via GitHub)" <gi...@apache.org> on 2024/02/05 07:07:41 UTC
[PR] [SPARK-46975][PS] Move `to_{hdf, feather, stata}` to the fallback list [spark]
zhengruifeng opened a new pull request, #45026:
URL: https://github.com/apache/spark/pull/45026
### What changes were proposed in this pull request?
Move `to_{hdf, feather, stata}` to the fallback list
### Why are the changes needed?
they should only be available in fallback mode
### Does this PR introduce _any_ user-facing change?
no, since pervious changes have not been released
### How was this patch tested?
updated tests
### Was this patch authored or co-authored using generative AI tooling?
no
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-46975][PS] Move `to_{hdf, feather, stata}` to the fallback list [spark]
Posted by "zhengruifeng (via GitHub)" <gi...@apache.org>.
zhengruifeng commented on code in PR #45026:
URL: https://github.com/apache/spark/pull/45026#discussion_r1480807590
##########
python/pyspark/pandas/frame.py:
##########
@@ -2648,123 +2648,6 @@ def to_latex(
psdf._to_internal_pandas(), self.to_latex, pd.DataFrame.to_latex, args
)
- def to_feather(
- self,
- path: Union[str, IO[str]],
- **kwargs: Any,
- ) -> None:
- """
- Write a DataFrame to the binary Feather format.
-
- .. note:: This method should only be used if the resulting DataFrame is expected
- to be small, as all the data is loaded into the driver's memory.
-
- .. versionadded:: 4.0.0
-
- Parameters
- ----------
- path : str, path object, file-like object
- String, path object (implementing ``os.PathLike[str]``), or file-like
- object implementing a binary ``write()`` function.
- **kwargs :
- Additional keywords passed to :func:`pyarrow.feather.write_feather`.
- This includes the `compression`, `compression_level`, `chunksize`
- and `version` keywords.
-
- Examples
- --------
- >>> df = ps.DataFrame([[1, 2, 3], [4, 5, 6]])
- >>> df.to_feather("file.feather") # doctest: +SKIP
- """
- # Make sure locals() call is at the top of the function so we don't capture local variables.
- args = locals()
-
- return validate_arguments_and_invoke_function(
- self._to_internal_pandas(), self.to_feather, pd.DataFrame.to_feather, args
- )
-
- def to_stata(
- self,
- path: Union[str, IO[str]],
- *,
- convert_dates: Optional[Dict] = None,
- write_index: bool = True,
- byteorder: Optional[str] = None,
- time_stamp: Optional[datetime.datetime] = None,
- data_label: Optional[str] = None,
- variable_labels: Optional[Dict] = None,
- version: Optional[int] = 114,
- convert_strl: Optional[Sequence[Name]] = None,
- compression: str = "infer",
- storage_options: Optional[str] = None,
- value_labels: Optional[Dict] = None,
- ) -> None:
- """
- Export DataFrame object to Stata dta format.
-
- .. note:: This method should only be used if the resulting DataFrame is expected
- to be small, as all the data is loaded into the driver's memory.
-
- .. versionadded:: 4.0.0
-
- Parameters
- ----------
- path : str, path object, or buffer
- String, path object (implementing ``os.PathLike[str]``), or file-like
- object implementing a binary ``write()`` function.
- convert_dates : dict
- Dictionary mapping columns containing datetime types to stata
- internal format to use when writing the dates. Options are 'tc',
- 'td', 'tm', 'tw', 'th', 'tq', 'ty'. Column can be either an integer
- or a name. Datetime columns that do not have a conversion type
- specified will be converted to 'tc'. Raises NotImplementedError if
- a datetime column has timezone information.
- write_index : bool
- Write the index to Stata dataset.
- byteorder : str
- Can be ">", "<", "little", or "big". default is `sys.byteorder`.
- time_stamp : datetime
- A datetime to use as file creation date. Default is the current
- time.
- data_label : str, optional
- A label for the data set. Must be 80 characters or smaller.
- variable_labels : dict
- Dictionary containing columns as keys and variable labels as
- values. Each label must be 80 characters or smaller.
- version : {{114, 117, 118, 119, None}}, default 114
- Version to use in the output dta file. Set to None to let pandas
- decide between 118 or 119 formats depending on the number of
- columns in the frame. Version 114 can be read by Stata 10 and
- later. Version 117 can be read by Stata 13 or later. Version 118
- is supported in Stata 14 and later. Version 119 is supported in
- Stata 15 and later. Version 114 limits string variables to 244
- characters or fewer while versions 117 and later allow strings
- with lengths up to 2,000,000 characters. Versions 118 and 119
- support Unicode characters, and version 119 supports more than
- 32,767 variables.
- convert_strl : list, optional
- List of column names to convert to string columns to Stata StrL
- format. Only available if version is 117. Storing strings in the
- StrL format can produce smaller dta files if strings have more than
- 8 characters and values are repeated.
- value_labels : dict of dicts
- Dictionary containing columns as keys and dictionaries of column value
- to labels as values. Labels for a single variable must be 32,000
- characters or smaller.
-
- Examples
- --------
- >>> df = ps.DataFrame({'animal': ['falcon', 'parrot', 'falcon', 'parrot'],
- ... 'speed': [350, 18, 361, 15]})
- >>> df.to_stata('animals.dta') # doctest: +SKIP
- """
- # Make sure locals() call is at the top of the function so we don't capture local variables.
- args = locals()
-
- return validate_arguments_and_invoke_function(
Review Comment:
I still feel a bit hesitant about how to change now.
the newly added `to_hdf/to_feather/to_stata` methods are actually consistent with existing `to_excel/to_markdown/etc` that also load all the data to the driver.
I think there are 3 options:
1, let `to_hdf/to_feather/to_stata` alone;
2, hide those methods, no docs, users can not see those methods, only usable when set the config (this PR);
3, just add if-else with the config in the implementations;
wdyt? @ueshin @xinrong-meng @HyukjinKwon
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-46975][PS] Move `to_{hdf, feather, stata}` to the fallback list [spark]
Posted by "ueshin (via GitHub)" <gi...@apache.org>.
ueshin commented on code in PR #45026:
URL: https://github.com/apache/spark/pull/45026#discussion_r1478918329
##########
python/pyspark/pandas/series.py:
##########
@@ -7233,6 +7233,9 @@ def __getattr__(self, item: str_type) -> Any:
if item.startswith("__"):
raise AttributeError(item)
if hasattr(MissingPandasLikeSeries, item):
+ if item in ["to_hdf"] and get_option("compute.pandas_fallback"):
Review Comment:
or how about just checking `hasattr(self, new_key)`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-46975][PS] Move `to_{hdf, feather, stata}` to the fallback list [spark]
Posted by "ueshin (via GitHub)" <gi...@apache.org>.
ueshin commented on code in PR #45026:
URL: https://github.com/apache/spark/pull/45026#discussion_r1478910397
##########
python/pyspark/pandas/tests/io/test_feather.py:
##########
@@ -34,7 +35,13 @@ def pdf(self):
def psdf(self):
return ps.from_pandas(self.pdf)
+ def test_disabled(self):
+ with self.assertRaises(PandasNotImplementedError):
+ self.psdf.to_feather("/tmp/f.feather")
+
def test_to_feather(self):
+ ps.set_option("compute.pandas_fallback", True)
Review Comment:
or we can use `option_context`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-46975][PS] Support dedicated fallback methods [spark]
Posted by "xinrong-meng (via GitHub)" <gi...@apache.org>.
xinrong-meng closed pull request #45026: [SPARK-46975][PS] Support dedicated fallback methods
URL: https://github.com/apache/spark/pull/45026
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-46975][PS] Move `to_{hdf, feather, stata}` to the fallback list [spark]
Posted by "xinrong-meng (via GitHub)" <gi...@apache.org>.
xinrong-meng commented on code in PR #45026:
URL: https://github.com/apache/spark/pull/45026#discussion_r1478862636
##########
python/pyspark/pandas/series.py:
##########
@@ -7233,6 +7233,9 @@ def __getattr__(self, item: str_type) -> Any:
if item.startswith("__"):
raise AttributeError(item)
if hasattr(MissingPandasLikeSeries, item):
+ if item in ["to_hdf"] and get_option("compute.pandas_fallback"):
Review Comment:
I'm wondering if it's better to define the fallback list as a constant, that also applies to `frame.py`. It's not necessary to include this in the current PR though
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-46975][PS] Move `to_{hdf, feather, stata}` to the fallback list [spark]
Posted by "zhengruifeng (via GitHub)" <gi...@apache.org>.
zhengruifeng commented on code in PR #45026:
URL: https://github.com/apache/spark/pull/45026#discussion_r1477866364
##########
python/pyspark/pandas/tests/io/test_feather.py:
##########
@@ -34,7 +35,13 @@ def pdf(self):
def psdf(self):
return ps.from_pandas(self.pdf)
+ def test_disabled(self):
+ with self.assertRaises(PandasNotImplementedError):
+ self.psdf.to_feather("/tmp/f.feather")
+
def test_to_feather(self):
+ ps.set_option("compute.pandas_fallback", True)
Review Comment:
good catch
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-46975][PS] Support dedicated fallback methods [spark]
Posted by "xinrong-meng (via GitHub)" <gi...@apache.org>.
xinrong-meng commented on PR #45026:
URL: https://github.com/apache/spark/pull/45026#issuecomment-1960084681
LGTM, thanks!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-46975][PS] Support dedicated fallback methods [spark]
Posted by "xinrong-meng (via GitHub)" <gi...@apache.org>.
xinrong-meng commented on PR #45026:
URL: https://github.com/apache/spark/pull/45026#issuecomment-1961866182
Merged to master! Thank you
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-46975][PS] Move `to_{hdf, feather, stata}` to the fallback list [spark]
Posted by "xinrong-meng (via GitHub)" <gi...@apache.org>.
xinrong-meng commented on code in PR #45026:
URL: https://github.com/apache/spark/pull/45026#discussion_r1478862636
##########
python/pyspark/pandas/series.py:
##########
@@ -7233,6 +7233,9 @@ def __getattr__(self, item: str_type) -> Any:
if item.startswith("__"):
raise AttributeError(item)
if hasattr(MissingPandasLikeSeries, item):
+ if item in ["to_hdf"] and get_option("compute.pandas_fallback"):
Review Comment:
I'm wondering if it's better to define the fallback list as a constant. `frame.py` ditto. It's not necessary to include this in the current PR though
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-46975][PS] Move `to_{hdf, feather, stata}` to the fallback list [spark]
Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on code in PR #45026:
URL: https://github.com/apache/spark/pull/45026#discussion_r1477781413
##########
python/pyspark/pandas/frame.py:
##########
@@ -2648,123 +2648,6 @@ def to_latex(
psdf._to_internal_pandas(), self.to_latex, pd.DataFrame.to_latex, args
)
- def to_feather(
- self,
- path: Union[str, IO[str]],
- **kwargs: Any,
- ) -> None:
- """
- Write a DataFrame to the binary Feather format.
-
- .. note:: This method should only be used if the resulting DataFrame is expected
- to be small, as all the data is loaded into the driver's memory.
-
- .. versionadded:: 4.0.0
-
- Parameters
- ----------
- path : str, path object, file-like object
- String, path object (implementing ``os.PathLike[str]``), or file-like
- object implementing a binary ``write()`` function.
- **kwargs :
- Additional keywords passed to :func:`pyarrow.feather.write_feather`.
- This includes the `compression`, `compression_level`, `chunksize`
- and `version` keywords.
-
- Examples
- --------
- >>> df = ps.DataFrame([[1, 2, 3], [4, 5, 6]])
- >>> df.to_feather("file.feather") # doctest: +SKIP
- """
- # Make sure locals() call is at the top of the function so we don't capture local variables.
- args = locals()
-
- return validate_arguments_and_invoke_function(
- self._to_internal_pandas(), self.to_feather, pd.DataFrame.to_feather, args
- )
-
- def to_stata(
- self,
- path: Union[str, IO[str]],
- *,
- convert_dates: Optional[Dict] = None,
- write_index: bool = True,
- byteorder: Optional[str] = None,
- time_stamp: Optional[datetime.datetime] = None,
- data_label: Optional[str] = None,
- variable_labels: Optional[Dict] = None,
- version: Optional[int] = 114,
- convert_strl: Optional[Sequence[Name]] = None,
- compression: str = "infer",
- storage_options: Optional[str] = None,
- value_labels: Optional[Dict] = None,
- ) -> None:
- """
- Export DataFrame object to Stata dta format.
-
- .. note:: This method should only be used if the resulting DataFrame is expected
- to be small, as all the data is loaded into the driver's memory.
-
- .. versionadded:: 4.0.0
-
- Parameters
- ----------
- path : str, path object, or buffer
- String, path object (implementing ``os.PathLike[str]``), or file-like
- object implementing a binary ``write()`` function.
- convert_dates : dict
- Dictionary mapping columns containing datetime types to stata
- internal format to use when writing the dates. Options are 'tc',
- 'td', 'tm', 'tw', 'th', 'tq', 'ty'. Column can be either an integer
- or a name. Datetime columns that do not have a conversion type
- specified will be converted to 'tc'. Raises NotImplementedError if
- a datetime column has timezone information.
- write_index : bool
- Write the index to Stata dataset.
- byteorder : str
- Can be ">", "<", "little", or "big". default is `sys.byteorder`.
- time_stamp : datetime
- A datetime to use as file creation date. Default is the current
- time.
- data_label : str, optional
- A label for the data set. Must be 80 characters or smaller.
- variable_labels : dict
- Dictionary containing columns as keys and variable labels as
- values. Each label must be 80 characters or smaller.
- version : {{114, 117, 118, 119, None}}, default 114
- Version to use in the output dta file. Set to None to let pandas
- decide between 118 or 119 formats depending on the number of
- columns in the frame. Version 114 can be read by Stata 10 and
- later. Version 117 can be read by Stata 13 or later. Version 118
- is supported in Stata 14 and later. Version 119 is supported in
- Stata 15 and later. Version 114 limits string variables to 244
- characters or fewer while versions 117 and later allow strings
- with lengths up to 2,000,000 characters. Versions 118 and 119
- support Unicode characters, and version 119 supports more than
- 32,767 variables.
- convert_strl : list, optional
- List of column names to convert to string columns to Stata StrL
- format. Only available if version is 117. Storing strings in the
- StrL format can produce smaller dta files if strings have more than
- 8 characters and values are repeated.
- value_labels : dict of dicts
- Dictionary containing columns as keys and dictionaries of column value
- to labels as values. Labels for a single variable must be 32,000
- characters or smaller.
-
- Examples
- --------
- >>> df = ps.DataFrame({'animal': ['falcon', 'parrot', 'falcon', 'parrot'],
- ... 'speed': [350, 18, 361, 15]})
- >>> df.to_stata('animals.dta') # doctest: +SKIP
- """
- # Make sure locals() call is at the top of the function so we don't capture local variables.
- args = locals()
-
- return validate_arguments_and_invoke_function(
Review Comment:
Actually I think we should keep the implementation as is here, and just add an if-else with `compute.pandas_fallback` (and treat those as just special cases) ....
By using the fallback one, it will write the file into one of the executors, which wouldn't be quite useful ..
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-46975][PS] Move `to_{hdf, feather, stata}` to the fallback list [spark]
Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on code in PR #45026:
URL: https://github.com/apache/spark/pull/45026#discussion_r1477779881
##########
python/pyspark/pandas/tests/io/test_feather.py:
##########
@@ -34,7 +35,13 @@ def pdf(self):
def psdf(self):
return ps.from_pandas(self.pdf)
+ def test_disabled(self):
+ with self.assertRaises(PandasNotImplementedError):
+ self.psdf.to_feather("/tmp/f.feather")
+
def test_to_feather(self):
+ ps.set_option("compute.pandas_fallback", True)
Review Comment:
try finally?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-46975][PS] Move `to_{hdf, feather, stata}` to the fallback list [spark]
Posted by "zhengruifeng (via GitHub)" <gi...@apache.org>.
zhengruifeng commented on code in PR #45026:
URL: https://github.com/apache/spark/pull/45026#discussion_r1477865928
##########
python/pyspark/pandas/frame.py:
##########
@@ -2648,123 +2648,6 @@ def to_latex(
psdf._to_internal_pandas(), self.to_latex, pd.DataFrame.to_latex, args
)
- def to_feather(
- self,
- path: Union[str, IO[str]],
- **kwargs: Any,
- ) -> None:
- """
- Write a DataFrame to the binary Feather format.
-
- .. note:: This method should only be used if the resulting DataFrame is expected
- to be small, as all the data is loaded into the driver's memory.
-
- .. versionadded:: 4.0.0
-
- Parameters
- ----------
- path : str, path object, file-like object
- String, path object (implementing ``os.PathLike[str]``), or file-like
- object implementing a binary ``write()`` function.
- **kwargs :
- Additional keywords passed to :func:`pyarrow.feather.write_feather`.
- This includes the `compression`, `compression_level`, `chunksize`
- and `version` keywords.
-
- Examples
- --------
- >>> df = ps.DataFrame([[1, 2, 3], [4, 5, 6]])
- >>> df.to_feather("file.feather") # doctest: +SKIP
- """
- # Make sure locals() call is at the top of the function so we don't capture local variables.
- args = locals()
-
- return validate_arguments_and_invoke_function(
- self._to_internal_pandas(), self.to_feather, pd.DataFrame.to_feather, args
- )
-
- def to_stata(
- self,
- path: Union[str, IO[str]],
- *,
- convert_dates: Optional[Dict] = None,
- write_index: bool = True,
- byteorder: Optional[str] = None,
- time_stamp: Optional[datetime.datetime] = None,
- data_label: Optional[str] = None,
- variable_labels: Optional[Dict] = None,
- version: Optional[int] = 114,
- convert_strl: Optional[Sequence[Name]] = None,
- compression: str = "infer",
- storage_options: Optional[str] = None,
- value_labels: Optional[Dict] = None,
- ) -> None:
- """
- Export DataFrame object to Stata dta format.
-
- .. note:: This method should only be used if the resulting DataFrame is expected
- to be small, as all the data is loaded into the driver's memory.
-
- .. versionadded:: 4.0.0
-
- Parameters
- ----------
- path : str, path object, or buffer
- String, path object (implementing ``os.PathLike[str]``), or file-like
- object implementing a binary ``write()`` function.
- convert_dates : dict
- Dictionary mapping columns containing datetime types to stata
- internal format to use when writing the dates. Options are 'tc',
- 'td', 'tm', 'tw', 'th', 'tq', 'ty'. Column can be either an integer
- or a name. Datetime columns that do not have a conversion type
- specified will be converted to 'tc'. Raises NotImplementedError if
- a datetime column has timezone information.
- write_index : bool
- Write the index to Stata dataset.
- byteorder : str
- Can be ">", "<", "little", or "big". default is `sys.byteorder`.
- time_stamp : datetime
- A datetime to use as file creation date. Default is the current
- time.
- data_label : str, optional
- A label for the data set. Must be 80 characters or smaller.
- variable_labels : dict
- Dictionary containing columns as keys and variable labels as
- values. Each label must be 80 characters or smaller.
- version : {{114, 117, 118, 119, None}}, default 114
- Version to use in the output dta file. Set to None to let pandas
- decide between 118 or 119 formats depending on the number of
- columns in the frame. Version 114 can be read by Stata 10 and
- later. Version 117 can be read by Stata 13 or later. Version 118
- is supported in Stata 14 and later. Version 119 is supported in
- Stata 15 and later. Version 114 limits string variables to 244
- characters or fewer while versions 117 and later allow strings
- with lengths up to 2,000,000 characters. Versions 118 and 119
- support Unicode characters, and version 119 supports more than
- 32,767 variables.
- convert_strl : list, optional
- List of column names to convert to string columns to Stata StrL
- format. Only available if version is 117. Storing strings in the
- StrL format can produce smaller dta files if strings have more than
- 8 characters and values are repeated.
- value_labels : dict of dicts
- Dictionary containing columns as keys and dictionaries of column value
- to labels as values. Labels for a single variable must be 32,000
- characters or smaller.
-
- Examples
- --------
- >>> df = ps.DataFrame({'animal': ['falcon', 'parrot', 'falcon', 'parrot'],
- ... 'speed': [350, 18, 361, 15]})
- >>> df.to_stata('animals.dta') # doctest: +SKIP
- """
- # Make sure locals() call is at the top of the function so we don't capture local variables.
- args = locals()
-
- return validate_arguments_and_invoke_function(
Review Comment:
got it, will update it tmr
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-46975][PS] Move `to_{hdf, feather, stata}` to the fallback list [spark]
Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on code in PR #45026:
URL: https://github.com/apache/spark/pull/45026#discussion_r1480858948
##########
python/pyspark/pandas/frame.py:
##########
@@ -2648,123 +2648,6 @@ def to_latex(
psdf._to_internal_pandas(), self.to_latex, pd.DataFrame.to_latex, args
)
- def to_feather(
- self,
- path: Union[str, IO[str]],
- **kwargs: Any,
- ) -> None:
- """
- Write a DataFrame to the binary Feather format.
-
- .. note:: This method should only be used if the resulting DataFrame is expected
- to be small, as all the data is loaded into the driver's memory.
-
- .. versionadded:: 4.0.0
-
- Parameters
- ----------
- path : str, path object, file-like object
- String, path object (implementing ``os.PathLike[str]``), or file-like
- object implementing a binary ``write()`` function.
- **kwargs :
- Additional keywords passed to :func:`pyarrow.feather.write_feather`.
- This includes the `compression`, `compression_level`, `chunksize`
- and `version` keywords.
-
- Examples
- --------
- >>> df = ps.DataFrame([[1, 2, 3], [4, 5, 6]])
- >>> df.to_feather("file.feather") # doctest: +SKIP
- """
- # Make sure locals() call is at the top of the function so we don't capture local variables.
- args = locals()
-
- return validate_arguments_and_invoke_function(
- self._to_internal_pandas(), self.to_feather, pd.DataFrame.to_feather, args
- )
-
- def to_stata(
- self,
- path: Union[str, IO[str]],
- *,
- convert_dates: Optional[Dict] = None,
- write_index: bool = True,
- byteorder: Optional[str] = None,
- time_stamp: Optional[datetime.datetime] = None,
- data_label: Optional[str] = None,
- variable_labels: Optional[Dict] = None,
- version: Optional[int] = 114,
- convert_strl: Optional[Sequence[Name]] = None,
- compression: str = "infer",
- storage_options: Optional[str] = None,
- value_labels: Optional[Dict] = None,
- ) -> None:
- """
- Export DataFrame object to Stata dta format.
-
- .. note:: This method should only be used if the resulting DataFrame is expected
- to be small, as all the data is loaded into the driver's memory.
-
- .. versionadded:: 4.0.0
-
- Parameters
- ----------
- path : str, path object, or buffer
- String, path object (implementing ``os.PathLike[str]``), or file-like
- object implementing a binary ``write()`` function.
- convert_dates : dict
- Dictionary mapping columns containing datetime types to stata
- internal format to use when writing the dates. Options are 'tc',
- 'td', 'tm', 'tw', 'th', 'tq', 'ty'. Column can be either an integer
- or a name. Datetime columns that do not have a conversion type
- specified will be converted to 'tc'. Raises NotImplementedError if
- a datetime column has timezone information.
- write_index : bool
- Write the index to Stata dataset.
- byteorder : str
- Can be ">", "<", "little", or "big". default is `sys.byteorder`.
- time_stamp : datetime
- A datetime to use as file creation date. Default is the current
- time.
- data_label : str, optional
- A label for the data set. Must be 80 characters or smaller.
- variable_labels : dict
- Dictionary containing columns as keys and variable labels as
- values. Each label must be 80 characters or smaller.
- version : {{114, 117, 118, 119, None}}, default 114
- Version to use in the output dta file. Set to None to let pandas
- decide between 118 or 119 formats depending on the number of
- columns in the frame. Version 114 can be read by Stata 10 and
- later. Version 117 can be read by Stata 13 or later. Version 118
- is supported in Stata 14 and later. Version 119 is supported in
- Stata 15 and later. Version 114 limits string variables to 244
- characters or fewer while versions 117 and later allow strings
- with lengths up to 2,000,000 characters. Versions 118 and 119
- support Unicode characters, and version 119 supports more than
- 32,767 variables.
- convert_strl : list, optional
- List of column names to convert to string columns to Stata StrL
- format. Only available if version is 117. Storing strings in the
- StrL format can produce smaller dta files if strings have more than
- 8 characters and values are repeated.
- value_labels : dict of dicts
- Dictionary containing columns as keys and dictionaries of column value
- to labels as values. Labels for a single variable must be 32,000
- characters or smaller.
-
- Examples
- --------
- >>> df = ps.DataFrame({'animal': ['falcon', 'parrot', 'falcon', 'parrot'],
- ... 'speed': [350, 18, 361, 15]})
- >>> df.to_stata('animals.dta') # doctest: +SKIP
- """
- # Make sure locals() call is at the top of the function so we don't capture local variables.
- args = locals()
-
- return validate_arguments_and_invoke_function(
Review Comment:
hmmmm ... okay .. I am fine with leaving it as is for now ....
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org