Numpy, TypeError: Could not be cast from dtype('<M8[us]') to dtype('<M8[D]')

后端 未结 1 1053
天命终不由人
天命终不由人 2021-01-12 03:35

I\'m trying to find out number of business days until a specific date and get the following error:

import numpy as np
import pandas_market_calendars as mcal         


        
1条回答
  •  自闭症患者
    2021-01-12 04:03

    You should pass dates to busday_count rather than datetimes:

    In [11]: today = datetime.now()
        ...: expiration = datetime(2019,2,13,0,0)
        ...:
        ...: days_to_expiration = np.busday_count(today.date(),expiration.date(),holidays=holidays)
        ...: print(days_to_expiration)
    11
    

    0 讨论(0)
提交回复
热议问题