在 pyspark 模式中指定字符串数组

specify array of string in pyspark schema

如何在 pyspark sql 架构中指定字符串数组。 我不想使用 StructFields。

在下面的例子中,城市在数组列表中。

schema = "country string, cities array(string)"
df=spark.read.csv(file_path,schema=schema)

使用<>代替括号

schema = "country string, cities array<string>"