You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "HyukjinKwon (via GitHub)" <gi...@apache.org> on 2023/05/31 06:59:56 UTC
[GitHub] [spark] HyukjinKwon commented on a diff in pull request #41396: [SPARK-43892] add autocomplete support for `df[|]` in `pyspark.sql.dataframe.DataFrame`
HyukjinKwon commented on code in PR #41396:
URL: https://github.com/apache/spark/pull/41396#discussion_r1211177500
##########
python/pyspark/sql/dataframe.py:
##########
@@ -4868,6 +4868,22 @@ def freqItems(
self._jdf.stat().freqItems(_to_seq(self._sc, cols), support), self.sparkSession
)
+ def _ipython_key_completions_(self) -> List[str]:
+ """Returns the names of columns in this :class:`DataFrame`.
+
+ Examples
+ --------
+ >>> df = spark.createDataFrame([(2, "Alice"), (5, "Bob")], ["age", "name"])
+ >>> df._ipython_key_completions_()
+ ['age', 'name']
+
+ Would return illegal identifiers.
+ >>> df = spark.createDataFrame([(2, "Alice"), (5, "Bob")], ["age 1", "name?1"])
+ >>> df._ipython_key_completions_()
+ ['age 1', 'name?1']
+ """
+ return self.columns
Review Comment:
shouldn't it call `__dir__`?
--
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