petern48 commented on code in PR #176:
URL: https://github.com/apache/sedona-db/pull/176#discussion_r2400453179
##########
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
+
+ return columns
Review Comment:
```suggestion
return self._impl.columns()
```
I think we should implement this in Rust, adding the below code
[here](https://github.com/apache/sedona-db/blob/a15844b4ff9c7e9416b8f1c1c07ad81d908a89cd/python/sedonadb/src/dataframe.rs#L62).
To test the updated Rust code locally, you'll want to run `maturin develop`
from the `python/sedonadb/` directory. You might need to `pip install maturin`.
```rust
fn columns(&self) -> Vec<String> {
self.inner
.schema()
.fields()
.iter()
.map(|f| f.name().to_string())
.collect()
}
```
--
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]