timsaucer commented on issue #752:
URL:
https://github.com/apache/datafusion-python/issues/752#issuecomment-2297702463
This turned out to be easier than I expected. Right now I have it importing
using the upstream pycapsule implementation and I'm exporting DataFrame. Is
there anything else you think needs exporting?
```
from datafusion import lit, SessionContext
import nanoarrow as na
import pyarrow as pa
ctx = SessionContext()
table = pa.table({"a": [1, 2, 3, 4], "b": ["a", "b", "c", "d"]})
print(table)
df = ctx.from_arrow_table(table).with_column("c", lit(3))
df.show()
nd = na.Array(df)
print(nd)
```
Produces
```
pyarrow.Table
a: int64
b: string
----
a: [[1,2,3,4]]
b: [["a","b","c","d"]]
DataFrame()
+---+---+---+
| a | b | c |
+---+---+---+
| 1 | a | 3 |
| 2 | b | 3 |
| 3 | c | 3 |
| 4 | d | 3 |
+---+---+---+
nanoarrow.Array<non-nullable struct<a: int64, b: string, c: int64>>[4]
{'a': 1, 'b': 'a', 'c': 3}
{'a': 2, 'b': 'b', 'c': 3}
{'a': 3, 'b': 'c', 'c': 3}
{'a': 4, 'b': 'd', 'c': 3}
```
I'll put up a PR after I've had time to write up some good unit tests.
--
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]