'How to correctly import pyspark.sql.functions?
from pyspark.sql.functions import isnan, when, count, sum , etc...
It is very tiresome adding all of it. Is there a way to import all of it at once?
Solution 1:[1]
You can try to use from pyspark.sql.functions import *. This method may lead to namespace coverage, such as pyspark sum function covering python built-in sum function.
Another insurance method: import pyspark.sql.functions as F, use method: F.sum.
Solution 2:[2]
Simply:
import pyspark.sql.functions as f
And use it as:
f.sum(...)
f.to_date(...)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | 过过招 |
| Solution 2 | user3426711 |
