Dec-31-2020, 03:00 PM
See this SO post:
https://stackoverflow.com/questions/3191...with-numba
Essentially pandas store all datetimes in datetime64[ns] format only (i.e. down to nanoseconds), but busday_count requires datetimes in datetime64[D] format.
One option is to convert the dates to datetime64[D] format and store it as a numpy array. Something like:
https://stackoverflow.com/questions/3191...with-numba
Essentially pandas store all datetimes in datetime64[ns] format only (i.e. down to nanoseconds), but busday_count requires datetimes in datetime64[D] format.
One option is to convert the dates to datetime64[D] format and store it as a numpy array. Something like:
import pandas as pd import numpy as np df = pd.read_csv('test11.csv', parse_dates = [1,2]) start_dates = np.array(df['Start_Date'].values.astype('datetime64[D]')) complete_dates = np.array(df['Complete_Date'].values.astype('datetime64[D]')) df['TAT'] = np.busday_count(start_dates, complete_dates) print(df)
Output: Title Start_Date Complete_Date TAT
0 projTitle 2020-01-19 2020-01-26 5
1 projTitle2 2020-02-11 2020-02-15 4