Login and get coding
get_datesmethod given the following:
- a listing of date strings in unknown date format and
enumclass which contains allowed/supported date formats
Although the following assignment text is wordy, once you will see test cases the task definition will become clearer.
get_datesmethod will return a list of date strings in the format yyyy-mm-dd.
The date format of input date strings will be inferred based on the most prevalent allowed date format of items in the list. Allowed/supported date formats are defined in an
The most prevalent allowed date format of items must represent a single most frequent date format. If there are two most frequent formats with the same frequency raise a (custom)
Items in an input list can be in any format no matter whether or not this format is listed in the DateFormat
enumclass. Items can be even values which cannot represent a date at all. Those items are nonparsable. If the frequency of nonparsable elements is higher than the frequency of other allowed date formats (counted individually for each format) raise a custom
Once you have the most prevalent date format, parse dates in an input list and return them as a list of strings in the format yyyy-mm-dd.
Dates which are not parsable replace with the string Invalid.
Important note: the list of allowed/supported date formats is supposed to be stored in the
DateFormat enumclass only. The
DateFormat enumclass is subject of change and this change is not under your control.
As a hint, you are provided with a helper method
_maybe_DFswhich shows how to work with the
117 out of 119 users completed this Bite.
Will you be Pythonista #118 to crack this Bite?
Resolution time: ~77 min. (avg. submissions of 5-240 min.)
Pythonistas rate this Bite 6.67 on a 1-10 difficulty scale.
» Up for a challenge? 💪