Google News
logo
PySpark - Interview Questions
What is PySpark ArrayType? Give an example to explain it well.
PySpark ArrayType is a collection data type that extends the PySpark's DataType class, which is the superclass for all kinds. The PySpark ArrayType contains only the same types of items. The ArraType() method can also be used to construct an instance of an ArrayType.

It accepts two arguments:

valueType : The valueType should extend the DataType class in PySpark.
valueContainsNull : It is an optional argument. It specifies whether a value can accept null and is set to True by default.

Example :
from pyspark.sql.types import StringType, ArrayType  
arrayCol = ArrayType(StringType(),False)  ?
Advertisement