Skip to content

[MINOR][PYTHON][DOCS] Fix types and docstring in DataFrame.toDF#38834

Closed
HyukjinKwon wants to merge 1 commit intoapache:masterfrom
HyukjinKwon:minor-docs-todf
Closed

[MINOR][PYTHON][DOCS] Fix types and docstring in DataFrame.toDF#38834
HyukjinKwon wants to merge 1 commit intoapache:masterfrom
HyukjinKwon:minor-docs-todf

Conversation

@HyukjinKwon
Copy link
Member

What changes were proposed in this pull request?

df.toDF cannot take Columns:

>>> df.toDF(df.id)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/.../spark/python/pyspark/sql/dataframe.py", line 4606, in toDF
    jdf = self._jdf.toDF(self._jseq(cols))
  File "/.../spark/python/pyspark/sql/dataframe.py", line 2413, in _jseq
    return _to_seq(self.sparkSession._sc, cols, converter)
  File "/.../spark/python/pyspark/sql/column.py", line 88, in _to_seq
    return sc._jvm.PythonUtils.toSeq(cols)
  File "/.../spark/python/lib/py4j-0.10.9.7-src.zip/py4j/java_gateway.py", line 1314, in __call__
  File "/.../spark/python/lib/py4j-0.10.9.7-src.zip/py4j/java_gateway.py", line 1277, in _build_args
  File "/.../spark/python/lib/py4j-0.10.9.7-src.zip/py4j/java_gateway.py", line 1264, in _get_args
  File "/.../spark/python/lib/py4j-0.10.9.7-src.zip/py4j/java_collections.py", line 511, in convert
  File "/.../spark/python/lib/py4j-0.10.9.7-src.zip/py4j/java_gateway.py", line 1314, in __call__
  File "/.../spark/python/lib/py4j-0.10.9.7-src.zip/py4j/java_gateway.py", line 1277, in _build_args
  File "/.../forked/spark/python/lib/py4j-0.10.9.7-src.zip/py4j/java_gateway.py", line 1264, in _get_args
  File "/.../spark/python/lib/py4j-0.10.9.7-src.zip/py4j/java_collections.py", line 510, in convert
  File "/.../spark/python/pyspark/sql/column.py", line 622, in __iter__
    raise TypeError("Column is not iterable")
TypeError: Column is not iterable

This PR fixes the type and docstrings to remove the mention about Column

Why are the changes needed?

To provide the correct documentation to the end users.

Does this PR introduce any user-facing change?

No for the main codes.
Yes for the docs.

How was this patch tested?

CI in this PR should verify it via Python linters.

@HyukjinKwon HyukjinKwon changed the title [MINOR][DOCS] Fix types and docstring in DataFrame.toDF [MINOR][PYTHON][DOCS] Fix types and docstring in DataFrame.toDF Nov 29, 2022
@amaliujia
Copy link
Contributor

LGTM

@HyukjinKwon
Copy link
Member Author

Merged to master.

@zhengruifeng
Copy link
Contributor

late lgtm, thanks

beliefer pushed a commit to beliefer/spark that referenced this pull request Dec 15, 2022
### What changes were proposed in this pull request?

`df.toDF` cannot take `Column`s:

```python
>>> df.toDF(df.id)
```
```
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/.../spark/python/pyspark/sql/dataframe.py", line 4606, in toDF
    jdf = self._jdf.toDF(self._jseq(cols))
  File "/.../spark/python/pyspark/sql/dataframe.py", line 2413, in _jseq
    return _to_seq(self.sparkSession._sc, cols, converter)
  File "/.../spark/python/pyspark/sql/column.py", line 88, in _to_seq
    return sc._jvm.PythonUtils.toSeq(cols)
  File "/.../spark/python/lib/py4j-0.10.9.7-src.zip/py4j/java_gateway.py", line 1314, in __call__
  File "/.../spark/python/lib/py4j-0.10.9.7-src.zip/py4j/java_gateway.py", line 1277, in _build_args
  File "/.../spark/python/lib/py4j-0.10.9.7-src.zip/py4j/java_gateway.py", line 1264, in _get_args
  File "/.../spark/python/lib/py4j-0.10.9.7-src.zip/py4j/java_collections.py", line 511, in convert
  File "/.../spark/python/lib/py4j-0.10.9.7-src.zip/py4j/java_gateway.py", line 1314, in __call__
  File "/.../spark/python/lib/py4j-0.10.9.7-src.zip/py4j/java_gateway.py", line 1277, in _build_args
  File "/.../forked/spark/python/lib/py4j-0.10.9.7-src.zip/py4j/java_gateway.py", line 1264, in _get_args
  File "/.../spark/python/lib/py4j-0.10.9.7-src.zip/py4j/java_collections.py", line 510, in convert
  File "/.../spark/python/pyspark/sql/column.py", line 622, in __iter__
    raise TypeError("Column is not iterable")
TypeError: Column is not iterable
```

This PR fixes the type and docstrings to remove the mention about `Column`

### Why are the changes needed?

To provide the correct documentation to the end users.

### Does this PR introduce _any_ user-facing change?

No for the main codes.
Yes for the docs.

### How was this patch tested?

CI in this PR should verify it via Python linters.

Closes apache#38834 from HyukjinKwon/minor-docs-todf.

Authored-by: Hyukjin Kwon <gurwls223@apache.org>
Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
beliefer pushed a commit to beliefer/spark that referenced this pull request Dec 18, 2022
### What changes were proposed in this pull request?

`df.toDF` cannot take `Column`s:

```python
>>> df.toDF(df.id)
```
```
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/.../spark/python/pyspark/sql/dataframe.py", line 4606, in toDF
    jdf = self._jdf.toDF(self._jseq(cols))
  File "/.../spark/python/pyspark/sql/dataframe.py", line 2413, in _jseq
    return _to_seq(self.sparkSession._sc, cols, converter)
  File "/.../spark/python/pyspark/sql/column.py", line 88, in _to_seq
    return sc._jvm.PythonUtils.toSeq(cols)
  File "/.../spark/python/lib/py4j-0.10.9.7-src.zip/py4j/java_gateway.py", line 1314, in __call__
  File "/.../spark/python/lib/py4j-0.10.9.7-src.zip/py4j/java_gateway.py", line 1277, in _build_args
  File "/.../spark/python/lib/py4j-0.10.9.7-src.zip/py4j/java_gateway.py", line 1264, in _get_args
  File "/.../spark/python/lib/py4j-0.10.9.7-src.zip/py4j/java_collections.py", line 511, in convert
  File "/.../spark/python/lib/py4j-0.10.9.7-src.zip/py4j/java_gateway.py", line 1314, in __call__
  File "/.../spark/python/lib/py4j-0.10.9.7-src.zip/py4j/java_gateway.py", line 1277, in _build_args
  File "/.../forked/spark/python/lib/py4j-0.10.9.7-src.zip/py4j/java_gateway.py", line 1264, in _get_args
  File "/.../spark/python/lib/py4j-0.10.9.7-src.zip/py4j/java_collections.py", line 510, in convert
  File "/.../spark/python/pyspark/sql/column.py", line 622, in __iter__
    raise TypeError("Column is not iterable")
TypeError: Column is not iterable
```

This PR fixes the type and docstrings to remove the mention about `Column`

### Why are the changes needed?

To provide the correct documentation to the end users.

### Does this PR introduce _any_ user-facing change?

No for the main codes.
Yes for the docs.

### How was this patch tested?

CI in this PR should verify it via Python linters.

Closes apache#38834 from HyukjinKwon/minor-docs-todf.

Authored-by: Hyukjin Kwon <gurwls223@apache.org>
Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
@HyukjinKwon HyukjinKwon deleted the minor-docs-todf branch January 15, 2024 00:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments