How can I calculate number of days between two dates ignoring weekends, using pyspark?
This is the exact same question as here, only I need to do this with pyspark.
I tried using a udf:
import numpy as np
from pyspark.sql.functions import udf
from pyspark.sql.types import IntegerType
@udf(returnType=IntegerType())
def dateDiffWeekdays(end, start):
return int(np.busday_count(start, end)) # numpy returns an `numpy.int64` type.
When using this udf, I get an error message:
ModuleNotFoundError: No module named 'numpy'
Does anyone know how to solve this? Or better yet, to solve this without a udf in native pyspark?
EDIT: I have numpy installed. Outside of a udf it works just fine.