Python 覆盖 itertools.chain 映射
Python coverting itertools.chain to map
我是 pyspark 的新手,正在尝试从一些产品代码中理解下面的代码。
test_map = {"A":1,"B":2, "C":3, "D":4}
test_mapping = create_map([lit(ele) for ele in chain(*test_map.items())])
上面的代码给我错误。
AttributeError: 'NoneType' object has no attribute '_jvm'
不确定那有什么问题。有人可以解释一下吗?
上面的代码没有任何问题。事实上,它不会“运行”任何东西,因为 Spark 转换是惰性的。
这是您的代码的实际结果:
print(test_mapping)
# Column<'map(A, 1, B, 2, C, 3, D, 4)'>
我是 pyspark 的新手,正在尝试从一些产品代码中理解下面的代码。
test_map = {"A":1,"B":2, "C":3, "D":4}
test_mapping = create_map([lit(ele) for ele in chain(*test_map.items())])
上面的代码给我错误。
AttributeError: 'NoneType' object has no attribute '_jvm'
不确定那有什么问题。有人可以解释一下吗?
上面的代码没有任何问题。事实上,它不会“运行”任何东西,因为 Spark 转换是惰性的。
这是您的代码的实际结果:
print(test_mapping)
# Column<'map(A, 1, B, 2, C, 3, D, 4)'>