PySpark is a powerful language for data manipulation and it’s full of tricks. Let’s discover some of them.
Control the Type of a NULL column
If you are creating a pysspark dataframe, but one of the columns contains only null values (None), how could you control the type of the column?
There is an interesting expression you can build using lit().cast() to control the type of a column with null values.
The following statement will add a new column or fix the type of an existing column containing only Null values.
from