Search code examples
pythonpython-3.xpandaspython-datetime

How to fix DatetimeIndex.union_many is deprecated warning in Python


I have the following code:

import datetime, pytz
import pandas_market_calendars as mcal

today_date = datetime.datetime.now(tz=pytz.timezone('US/Eastern'))
start_date = datetime.date(today_date.year - 5, today_date.month, today_date.day)

end_date = datetime.date(today_date.year + 2, today_date.month, today_date.day + 5)

nyse_calender = mcal.get_calendar('NYSE')
nyse_business_days = nyse_calender.schedule(start_date=start_date, end_date=end_date)

When I run this, I get the following warning:

 FutureWarning: DatetimeIndex.union_many is deprecated and will be removed in a future version. Use obj.union instead.   
  nyse_business_days = nyse_calender.schedule(start_date=start_date, end_date=end_date)

How am I supposed to solve this problem? The warning doesn't really help to take an action..


Solution

  • A PR for pandas_market_calendar was merged a couple of days ago which fixes this issue.