Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-41213][CONNECT][PYTHON] Implement DataFrame.__repr__ and DataFrame.dtypes #38735

Closed
wants to merge 1 commit into from

Conversation

zhengruifeng
Copy link
Contributor

What changes were proposed in this pull request?

Implement DataFrame.__repr__ and DataFrame.dtypes

Why are the changes needed?

For api coverage

Does this PR introduce any user-facing change?

yes

How was this patch tested?

added UT

init

init

init
@@ -115,6 +115,9 @@ def __init__(
self._cache: Dict[str, Any] = {}
self._session: "RemoteSparkSession" = session

def __repr__(self) -> str:
return "DataFrame[%s]" % (", ".join("%s: %s" % c for c in self.dtypes))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this follows the default behavior of

def __repr__(self) -> str:
if not self._support_repr_html and self.sparkSession._jconf.isReplEagerEvalEnabled():
vertical = False
return self._jdf.showString(
self.sparkSession._jconf.replEagerEvalMaxNumRows(),
self.sparkSession._jconf.replEagerEvalTruncate(),
vertical,
)
else:
return "DataFrame[%s]" % (", ".join("%s: %s" % c for c in self.dtypes))

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: is this public API?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will be invoked here:

In [1]: df = spark.createDataFrame([(10, 80, "Alice"), (5, None, "Bob"), (None, 10, "Tom"), (None, None, None)], schema=["age", "height", "name"])

In [2]: df
Out[2]: DataFrame[age: bigint, height: bigint, name: string]

In [3]: df.__repr__()
Out[3]: 'DataFrame[age: bigint, height: bigint, name: string]'

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the example!

@zhengruifeng
Copy link
Contributor Author

@HyukjinKwon
Copy link
Member

Merged to master.

@zhengruifeng
Copy link
Contributor Author

@HyukjinKwon thanks for the reviews

@zhengruifeng zhengruifeng deleted the connect_df_repr branch November 22, 2022 06:52
SandishKumarHN pushed a commit to SandishKumarHN/spark that referenced this pull request Dec 12, 2022
…taFrame.dtypes`

### What changes were proposed in this pull request?
Implement `DataFrame.__repr__` and `DataFrame.dtypes`

### Why are the changes needed?
For api coverage

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

### How was this patch tested?
added UT

Closes apache#38735 from zhengruifeng/connect_df_repr.

Authored-by: Ruifeng Zheng <ruifengz@apache.org>
Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
beliefer pushed a commit to beliefer/spark that referenced this pull request Dec 15, 2022
…taFrame.dtypes`

### What changes were proposed in this pull request?
Implement `DataFrame.__repr__` and `DataFrame.dtypes`

### Why are the changes needed?
For api coverage

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

### How was this patch tested?
added UT

Closes apache#38735 from zhengruifeng/connect_df_repr.

Authored-by: Ruifeng Zheng <ruifengz@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
…taFrame.dtypes`

### What changes were proposed in this pull request?
Implement `DataFrame.__repr__` and `DataFrame.dtypes`

### Why are the changes needed?
For api coverage

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

### How was this patch tested?
added UT

Closes apache#38735 from zhengruifeng/connect_df_repr.

Authored-by: Ruifeng Zheng <ruifengz@apache.org>
Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants