GitHub user davlee1972 edited a discussion: How to get columns and change their
names in a pyrrow compute expression.
Here is a sample pyarrow compute expression used for filtering data:
```
>>> import pyarrow.compute as pc
>>>
>>> exp = (pc.field("total") > 100) & (pc.field("items") < 10)
>>> exp
<pyarrow.compute.Expression ((total > 100) and (items < 10))>
```
My odd use case is that I need to modify the expression to:
```
>>> import pyarrow.compute as pc
>>>
>>> exp = (pc.field("TOTAL") > 100) & (pc.field("ITEMS") < 10)
>>> exp
<pyarrow.compute.Expression ((TOTAL > 100) and (ITEMS < 10))>
```
Some of my files have lower case column names and some files use upper case
column names. I know which files are upper case vs lower case so I need to take
a pyarrow compute expression using lower case column names including nested
columns in nested conditions and rewrite the expression with all upper case
column names.
Is there any way to create something like an abstract syntax tree to get all
possible column names and reconstruct the expression with all upper case column
names?
GitHub link: https://github.com/apache/arrow/discussions/48927
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]