You can achieve what you want, by processing each group in b
using the following code:
import pyarrow as pa
import pyarrow.compute as pc
table = pa.table({'a': [1, 2, 3, 4, 5, 6], 'b': ['x']*3 + ['y']*3})
unique_b = pc.unique(table['b'])
cumsum_list = []
b_list = []
for value in unique_b:
mask = pc.equal(table['b'], value)
group = table.filter(mask)
cumsum = pc.cumulative_sum(group['a'])
cumsum_list.extend(cumsum)
b_list.extend(group['b'])
final_result = pa.table({'a': cumsum_list, 'b': b_list})
To visualize the result you can convert it back to pandas using:
print(final_result.to_pandas())
which returns the following: