Skip to main content
Question

determine number of missing values in a subset of columns/attributes in a single feature


Forum|alt.badge.img

Hi all,

I'm not creative enough to think up a way to count, in a single feature, for a subset of 6 specific attributes the number of attributes that contain a missing value.

ex:

featureID, attA, attB, attC, attD, attE, attF, attG, attH

1234567, hi, <missing>, there, 1234, <missing>, friend, <missing>, <missing>

count of missing values in (attB-attG) = 3

the actual names of the attributes are not so structured, so I cannot use any cleverness there.

Can you suggest a wat to achieve this ?

Much Obliged !

Regards,

Ronald van Aalst

3 replies

Forum|alt.badge.img
  • Author
  • May 9, 2018
I found something about expressions, I am trying math expression

 

add(isnodata(@value(attB),isnodata(@value(attC),...) now, job is still processing.

 

 

 


jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • May 9, 2018

You could use a conditional to assign a value of 1 or 0 to a temporary attribute for each attribute in the subset, and then sum the temporary attributes.

 


takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • May 9, 2018

Hi @raalst, I don't think the isnodata function can be used here. The isnodata function is applicable only for raster cell values which are operated in the RasterExpressioinEvaluator.

As @jdh suggested, a possible way is to create new attributes with conditional value (if attribute is missing then 1 else 0) for each attribute then get the sum of them. You can use the AttributeCreator or the AttributeManager to do that.

Alternatively, this workflow could also be a solution, if you could define a special string that represent "missing" attribute exclusively.

  1. NullAttributeMapper: Assign the special string to every missing attribute.
  2. StringSeacher: Concatenate values of target attributes, find the special strings within the concatenated value, store them into a list.
  3. ListElementCounter: Count the number of elements in the list.

0684Q00000ArJkPQAV.png

Also, scripting might be effective in some case.

PythonCaller script example:

def countMissing(feature):
    attrs = ['attB''attC''attD''attE''attF''attG']
    count = 0
    for att in attrs:
        _, isMissing, _ = feature.getAttributeNullMissingAndType(att)
        if isMissing:
            count += 1
    feature.setAttribute('_count', count)

Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings