Skip to content
Advertisement

PySpark write a function to count non zero values of given columns

I want to have a function that will take as input column names and grouping conditions and based on that for each column it will return the count of non zero values for each column.

Something like this, but include non-zero condition as well.

JavaScript

Advertisement

Answer

You can use a list comprehension to generate the list of aggregation expressions:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement