[SPARK-39048][PYTHON] Refactor GroupBy._reduce_for_stat_function on accepted data types
[SPARK-39048][PYTHON] Refactor GroupBy._reduce_for_stat_function on accepted data types

### What changes were proposed in this pull request?
`Groupby._reduce_for_stat_function` is a common helper function leveraged by multiple statistical functions of GroupBy objects.

It defines parameters `only_numeric` and `bool_as_numeric` to control accepted Spark types.

To be consistent with pandas API, we may also have to introduce `str_as_numeric` for `sum` for example.

Instead of introducing parameters designated for each Spark type, the PR is proposed to introduce a parameter `accepted_spark_types` to specify accepted types of Spark columns to be aggregated.

That makes the helper function more extensible and clearer.

### Why are the changes needed?
To improve code extensibility and readability.

### Does this PR introduce _any_ user-facing change?
No.

### How was this patch tested?
Unit tests.

Closes #36382 from xinrong-databricks/groupby.refactor_param.

Authored-by: Xinrong Meng <f8e847d07d7307743be32495e91478c80c8e0110@databricks.com>
Signed-off-by: Takuya UESHIN <f070f8f0c50caeda5841963fc7b57e73e59dad56@databricks.com>

cloud-fan/spark,ueshin/apache-spark,srowen/spark,dongjoon-hyun/spark,WeichenXu123/spark,HyukjinKwon/spark,WeichenXu123/spark,nchammas/spark,gengliangwang/spark,nchammas/spark,hvanhovell/spark,holdenk/spark,cloud-fan/spark,gengliangwang/spark,vinodkc/spark,rednaxelafx/apache-spark,srowen/spark,holdenk/spark,hvanhovell/spark,ueshin/apache-spark,mahak/spark,vinodkc/spark,WeichenXu123/spark,srowen/spark,gengliangwang/spark,dongjoon-hyun/spark,rednaxelafx/apache-spark,JoshRosen/spark,hvanhovell/spark,shaneknapp/spark,rednaxelafx/apache-spark,gengliangwang/spark,witgo/spark,hvanhovell/spark,dongjoon-hyun/spark,rednaxelafx/apache-spark,zzcclp/spark,WeichenXu123/spark,mahak/spark,JoshRosen/spark,srowen/spark,witgo/spark,nchammas/spark,nchammas/spark,zzcclp/spark,ueshin/apache-spark,mahak/spark,shaneknapp/spark,wangyum/spark,shaneknapp/spark,hvanhovell/spark,shaneknapp/spark,witgo/spark,holdenk/spark,srowen/spark,cloud-fan/spark,hvanhovell/spark,HyukjinKwon/spark,HyukjinKwon/spark,cloud-fan/spark,witgo/spark,apache/spark,holdenk/spark,gengliangwang/spark,srowen/spark,ueshin/apache-spark,HyukjinKwon/spark,shaneknapp/spark,shaneknapp/spark,JoshRosen/spark,mahak/spark,wangyum/spark,JoshRosen/spark,WeichenXu123/spark,apache/spark,zero323/spark,zero323/spark,cloud-fan/spark,apache/spark,vinodkc/spark,mahak/spark,vinodkc/spark,ueshin/apache-spark,cloud-fan/spark,apache/spark,zero323/spark,HyukjinKwon/spark,zero323/spark,witgo/spark,ueshin/apache-spark,vinodkc/spark,dongjoon-hyun/spark,wangyum/spark,srowen/spark,vinodkc/spark,mahak/spark,apache/spark,JoshRosen/spark,HyukjinKwon/spark,rednaxelafx/apache-spark,zero323/spark,vinodkc/spark,rednaxelafx/apache-spark,zzcclp/spark,mahak/spark,JoshRosen/spark,wangyum/spark,zero323/spark,JoshRosen/spark,apache/spark,holdenk/spark,rednaxelafx/apache-spark,zzcclp/spark,shaneknapp/spark,ueshin/apache-spark,hvanhovell/spark,nchammas/spark,gengliangwang/spark,witgo/spark,wangyum/spark,zzcclp/spark,WeichenXu123/spark,WeichenXu123/spark,zzcclp/spark,dongjoon-hyun/spark,holdenk/spark,witgo/spark,nchammas/spark,wangyum/spark,zzcclp/spark,nchammas/spark,HyukjinKwon/spark,dongjoon-hyun/spark,wangyum/spark,apache/spark,zero323/spark,holdenk/spark,gengliangwang/spark,dongjoon-hyun/spark,cloud-fan/spark