p-vdp commented on code in PR #176:
URL: https://github.com/apache/sedona-db/pull/176#discussion_r2400342813
##########
python/sedonadb/python/sedonadb/dataframe.py:
##########
@@ -151,6 +151,29 @@ def count(self) -> int:
"""
return self._impl.count()
+ def __len__(self) -> int:
+ """Compute the number of rows in the DataFrame"""
+ return self.count()
+
+ @property
+ def columns(self) -> list[str]:
+ """Return the column names in the DataFrame"""
+ columns = list()
+ field_index = 0
+ while True:
+ try:
+ columns.append(self._impl.schema().field(field_index).name)
+ field_index += 1
+ except IndexError:
+ break
+
Review Comment:
Yes this is an ugly loop but `self._impl.schema()` isn't iterable. This
suggestion won't work without also modifying the return from
`PySedonaSchema.schema()`
--
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]