little-arhat opened a new issue, #33729:
URL: https://github.com/apache/arrow/issues/33729

   ### Describe the bug, including details regarding any error messages, 
version, and platform.
   
   Hello! 
   
   Filing this as a bug, though it could be feature request or even usage 
question.
   
   Code:
   ```
   import pyarrow
   from enum import Enum
   import pandas as pd
   
   class Unit(Enum):
       A = "A"
       B = "B"
   
   df = pd.DataFrame({'x': [Unit.A, Unit.B]})
   
   print(pyarrow.Table.from_pandas(df))
   ```
   
   Expected:
   
   smth like
   ```
   pyarrow.Table
   x: dictionary<values=string, indices=int8, ordered=0>
   ----
   x: [  -- dictionary:
   ["A","B"]  -- indices:
   [0,1]]
   ```
   
   Got:
   
   ```
   Traceback (most recent call last):
     File "x.py", line 12, in <module>
       print(pyarrow.Table.from_pandas(df))
     File "pyarrow/table.pxi", line 3475, in pyarrow.lib.Table.from_pandas
     File "/Users/a/venv/lib/python3.8/site-packages/pyarrow/pandas_compat.py", 
line 611, in dataframe_to_arrays
       arrays = [convert_column(c, f)
     File "/Users/avenv/lib/python3.8/site-packages/pyarrow/pandas_compat.py", 
line 611, in <listcomp>
       arrays = [convert_column(c, f)
     File "/Users/a/venv/lib/python3.8/site-packages/pyarrow/pandas_compat.py", 
line 598, in convert_column
       raise e
     File "/Users/a/venv/lib/python3.8/site-packages/pyarrow/pandas_compat.py", 
line 592, in convert_column
       result = pa.array(col, type=type_, from_pandas=True, safe=safe)
     File "pyarrow/array.pxi", line 316, in pyarrow.lib.array
     File "pyarrow/array.pxi", line 83, in pyarrow.lib._ndarray_to_array
     File "pyarrow/error.pxi", line 100, in pyarrow.lib.check_status
   pyarrow.lib.ArrowInvalid: ("Could not convert <Unit.A: 'A'> with type Unit: 
did not recognize Python value type when inferring an Arrow data type", 
'Conversion failed for column x with type object')
   ```
   
   Extracting `.name` from enum values and converting to `category` works as 
expected. 
   
   ### Component(s)
   
   Python


-- 
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]

Reply via email to