Home > Software design >  Pyarrow Table doesn't seem to have to_pylist() as a method
Pyarrow Table doesn't seem to have to_pylist() as a method

Time:05-18

pyarrow documentation says that the Table class has a method called to_pylist which should return a list of dictionaries.

https://arrow.apache.org/docs/python/generated/pyarrow.Table.html#pyarrow.Table.to_pylist

When I run their code example:

import pyarrow as pa
import pandas as pd
df = pd.DataFrame({'n_legs': [2, 4, 5, 100],
                   'animals': ["Flamingo", "Horse", "Brittle stars", "Centipede"]})
table = pa.Table.from_pandas(df)
table.to_pylist()

I get the following attributeerror:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: 'pyarrow.lib.Table' object has no attribute 'to_pylist'

Has to_pylist been removed or is there something wrong with my package?

CodePudding user response:

Method to_pylist was added to pa.Table in version 7.0.0. As suggested, could you check that the version of pyarrow you are using is not older?

  • Related