Skip to content

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
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 <[email protected]>
Signed-off-by: Hyukjin Kwon <[email protected]>
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 <[email protected]>
Signed-off-by: Hyukjin Kwon <[email protected]>
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 <[email protected]>
Signed-off-by: Hyukjin Kwon <[email protected]>
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