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