问题描述
我正在尝试用数字值重新编码一列,其中99和199代表缺失值。我想将其重新编码为(。),以便在应用条件时没有任何值,并保留所有其他值。例如,
如果test = 99或test = 199 then。 else =用其他值填充。
如何在HIVE中做到这一点?
解决方法
这没有道理。 99
和199
是数字,但.
不是。因此,我建议NULL
:
(case when test not in (99,199) then test end) as test_recoded
如果test
确实是一个字符串,那么您可以使用上述字符串或替代项:
(case when test not in ('99','199') then test else '.' end) as test_recoded