MCPcopy
hub / github.com/pandas-dev/pandas / merge_class

Method merge_class

pandas/tseries/holiday.py:550–582  ·  view source on GitHub ↗

Merge holiday calendars together. The base calendar will take precedence to other. The merge will be done based on each holiday's name. Parameters ---------- base : AbstractHolidayCalendar instance/subclass or array of Holiday objects

(base, other)

Source from the content-addressed store, hash-verified

548
549 @staticmethod
550 def merge_class(base, other):
551 """
552 Merge holiday calendars together. The base calendar
553 will take precedence to other. The merge will be done
554 based on each holiday's name.
555
556 Parameters
557 ----------
558 base : AbstractHolidayCalendar
559 instance/subclass or array of Holiday objects
560 other : AbstractHolidayCalendar
561 instance/subclass or array of Holiday objects
562 """
563 try:
564 other = other.rules
565 except AttributeError:
566 pass
567
568 if not isinstance(other, list):
569 other = [other]
570 other_holidays = {holiday.name: holiday for holiday in other}
571
572 try:
573 base = base.rules
574 except AttributeError:
575 pass
576
577 if not isinstance(base, list):
578 base = [base]
579 base_holidays = {holiday.name: holiday for holiday in base}
580
581 other_holidays.update(base_holidays)
582 return list(other_holidays.values())
583
584 def merge(self, other, inplace: bool = False):
585 """

Callers 2

mergeMethod · 0.95
HolidayCalendarFactoryFunction · 0.80

Calls 2

updateMethod · 0.45
valuesMethod · 0.45

Tested by

no test coverage detected