2021年3月19日星期五

How can I drop columns that are not part of a schema safely?

I have a dataframe that has columns : [A, B, ... M] and a schema that only requires few of the columns from the dataframe:

StructType([StructField(A, StringType(), False),              StructField(C, StringType(), True),              StructField(K, StringType(), True)])  

Since I do not own the schema, I do not have a list of all columns already available. Is there a way to safely and efficiently select columns as per the schema?

https://stackoverflow.com/questions/66717354/how-can-i-drop-columns-that-are-not-part-of-a-schema-safely March 20, 2021 at 09:06AM

没有评论:

发表评论