code: def clean_series(series, *args, **kwargs):
      
      if not series.dtype == np.dtype('O'):
          return series
      if any_generated((isinstance(v, datetime.datetime) for v in series)):
          series = series.apply(clip_datetime)
      if any_generated((isinstance(v, basestring) for v in series)):
          series = series.apply(encode)
      series = series.apply(try_float_int)
      return series
docs: Ensure all datetimes are valid Timestamp objects and dtype is np.datetime64[ns]
      >>> from datetime import timedelta
      >>> clean_series(pd.Series([datetime.datetime(1, 1, 1), 9, '1942', datetime.datetime(1970, 10, 23)]))
      0    1677-09-22 00:12:44+00:00
      1                            9
      2                         1942
      3    1970-10-23 00:00:00+00:00
      dtype: object
      >>> clean_series(pd.Series([datetime.datetime(1, 1, 1), datetime.datetime(3000, 10, 23)]))
      0             1677-09-22 00:12:44+00:00
      1   2262-04-11 23:47:16.854775+00:00
      dtype: datetime64[ns, UTC]