Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import calendar
- months_list = np.array([calendar.month_name[i] for i in range(1, 13)])
- class InconsistentDataError(Exception):
- pass
- def sort_month_names_by_profits(
- amounts_of_sold_subscriptions: np.ndarray,
- subscriptions_prices: np.ndarray,
- ascending: bool = True,
- ) -> list[str]:
- if amounts_of_sold_subscriptions.shape[1] != subscriptions_prices.shape[1]:
- raise InconsistentDataError
- income = amounts_of_sold_subscriptions * subscriptions_prices
- income_per_month = np.sum(income, axis=1)
- indices = np.argsort(income_per_month)
- res = months_list[indices]
- if not ascending:
- res = res[::-1]
- return res
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement