def _maybe_cache(arg, format, cache, convert_listlike):
from pandas import Series<EOL>cache_array = Series()<EOL>if cache:<EOL><INDENT>from pandas import Index<EOL>unique_dates = Index(arg).unique()<EOL>if len(unique_dates) < len(arg):<EOL><INDENT>cache_dates = convert_listlike(unique_dates.to_numpy(),<EOL>True, format)<EOL>cache_array = Series(cache_dates, index=unique_dates)<EOL><DEDENT><DEDENT>return cache_array<EOL>
Create a cache of unique dates from an array of dates

Parameters
----------
arg : integer, float, string, datetime, list, tuple, 1-d array, Series
format : string
    Strftime format to parse time
cache : boolean
    True attempts to create a cache of converted values
convert_listlike : function
    Conversion function to apply on dates

Returns
-------
cache_array : Series
    Cache of converted, unique dates. Can be empty