I believe currently updating array values is not possible by design. Using
the approach Michael pointed out you can create a new array to replace the
old one.
See this discussion [1] for more nuance.

Rok

[1] https://lists.apache.org/thread/kph2sk0nqc0yfcb39dmjmh3ljg4dpyfx

On Mon, Jul 4, 2022 at 1:15 PM Michael <[email protected]>
wrote:

> This section of the cookbook might help:
>
> https://arrow.apache.org/cookbook/py/data.html#filtering-arrays-using-a-mask
>
> Also these methods in the compute module.
>
>
> https://arrow.apache.org/docs/python/api/compute.html#selecting-multiplexing
> https://arrow.apache.org/docs/python/api/compute.html#selections
>
> Not at my computer, so apologies for not giving a direct example. I think
> coalesce might be the method you need.
>
>
> On Mon, Jul 4, 2022 at 12:44 PM H G <[email protected]> wrote:
>
>> iloc equivalent for selection by position and setting values?
>>
>> import pyarrow as pa
>> import pandas as pd
>> df = pd.DataFrame({'year': [2020, 2022, 2019, 2021],
>>                    'n_legs': [2, 4, 5, 100],
>>                    'animals': ["Flamingo", "Horse", "Brittle stars",
>> None]})
>> table = pa.Table.from_pandas(df)
>>
>> df.loc[df["animals"].isnull(), "animals"] = "new_value" # how do we
>> perform this in pyarrow?
>>
>> I did open this on github, but I assume it is not the forum for queries.
>>
>> Thanks
>>
> --
>
> Michael
>

Reply via email to