# The use of avg in Python calculator

**URL:** https://discourse.paraview.org/t/the-use-of-avg-in-python-calculator/15958
**Category:** ParaView Support
**Created:** [January 9, 2025, 10:13am UTC](https://discourse.paraview.org/t/the-use-of-avg-in-python-calculator/15958 "2025-01-09T10:13:29Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![shenbei](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/bbce88/32.png) [@shenbei](https://discourse.paraview.org/u/shenbei)
#### Post date: [January 9, 2025, 10:13am UTC](https://discourse.paraview.org/t/the-use-of-avg-in-python-calculator/15958/1 "2025-01-09T10:13:29Z")

</div>

I obtained the time averaged particle content (pvf) in this slice, but it is the time averaged value for each grid. Now I want to get the average value of these grid values. I choose to use Python calculator, but when I input it, it always gives an error. Is there any solution.

 ![image](https://discourse.paraview.org/uploads/default/original/2X/a/a594f7fe7ec0075d5c8b30ad6ca447f1e4594bf7.jpeg)

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [January 9, 2025, 1:47pm UTC](https://discourse.paraview.org/t/the-use-of-avg-in-python-calculator/15958/2 "2025-01-09T13:47:24Z")

</div>

Reduction operation cannot be performed using the python calculator, use either a Statistic filter like DescriptiveStatistic or use a Programmable Filter instead.

---

<div class="post-metadata">

### Author: ![sherin.sugathan](https://discourse.paraview.org/user_avatar/discourse.paraview.org/sherin.sugathan/32/15264_2.png) [@sherin.sugathan](https://discourse.paraview.org/u/sherin.sugathan)
#### Post date: [January 12, 2025, 10:16pm UTC](https://discourse.paraview.org/t/the-use-of-avg-in-python-calculator/15958/3 "2025-01-12T22:16:26Z")

</div>

I see that I can use something like `mean(inputs[0].CellData['ids'])`  
Is this something not recommended?

 ![image](https://discourse.paraview.org/uploads/default/original/2X/e/e518f3e36f71fff19ad67dfc9efa51e09f507ac9.png)

---

<div class="post-metadata">

### Author: ![shenbei](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/bbce88/32.png) [@shenbei](https://discourse.paraview.org/u/shenbei)
#### Post date: [January 14, 2025, 3:15am UTC](https://discourse.paraview.org/t/the-use-of-avg-in-python-calculator/15958/4 "2025-01-14T03:15:45Z")

</div>

Thank you for your reply. I will try it out

---

<div class="post-metadata">

### Author: ![shenbei](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/bbce88/32.png) [@shenbei](https://discourse.paraview.org/u/shenbei)
#### Post date: [January 14, 2025, 3:16am UTC](https://discourse.paraview.org/t/the-use-of-avg-in-python-calculator/15958/5 "2025-01-14T03:16:08Z")

</div>

Thank you for your reply

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [January 14, 2025, 7:47am UTC](https://discourse.paraview.org/t/the-use-of-avg-in-python-calculator/15958/6 "2025-01-14T07:47:18Z")

</div>

you are absolutely correct, that will compute means at the block level, I forgot about the possibility to select FieldData association 🙂
