HyukjinKwon commented on code in PR #42828:
URL: https://github.com/apache/spark/pull/42828#discussion_r1317985461
##########
python/pyspark/sql/dataframe.py:
##########
@@ -3455,8 +3455,14 @@ def __getitem__(self, item: Union[int, str, Column,
List, Tuple]) -> Union[Colum
return self.filter(item)
elif isinstance(item, (list, tuple)):
return self.select(*item)
- elif isinstance(item, int):
- jc = self._jdf.apply(self.columns[item])
+ elif isinstance(item, int) and not isinstance(item, bool):
+ if item < 0:
+ raise IndexError(f"Column index must be non-negative but got
{item}")
Review Comment:
and I think we can allow negative ones too.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]