我仍然处于学习pyspark的初始阶段,我发现下面的代码令人困惑。可以 有人,请给我解释一下
Code :
zipsSchema = smartphoneDF.schema
print(type(zipsSchema))
[**field** for field in zipsSchema]
What does "field" before "for" mean, and why is the entire statement enclosed in "[]" When I try to write the same
My code is as follows :
zipsSchema = smartphoneDF.schema
print(type(zipsSchema))
for field in zipsSchema
print(field)
field
是来自zipsSchema结构类型的元素我们可以使用python中的
[field for field in zipsSchema]
islist comprehension在单行中编写for循环,而不是创建空列表和列表中的附加元素Example:
正如您所看到的
fields_lc
,fields_fl
值是相同的,创建是不同的相关问题 更多 >
编程相关推荐