PySpark convert JSON to columns with error in dataframe

Viewed 44

I have a dataframe df

col
{"A":"ppp","B":"ee","C":"sad"........}
.
.
.

I am trying to use

schema = StructType([StructField("a", StringType()),StructField("b", StringType())])
df = df.withColumn('col',from_json('col',schema')).select(col('col'.*)

However, I get the below error due to data type mismatch: argument 1 requires string type however col is of map<string, string> type

0 Answers
Related