def cast(self, d):
        """
        Cast a single value to a :class:`datetime.datetime`.

        :param date_format:
            An optional :func:`datetime.strptime` format string for parsing
            datetimes in this column.
        :returns:
            :class:`datetime.datetime` or :code:`None`.
        """
        if isinstance(d, datetime.datetime) or d is None:
            return d
        elif isinstance(d, datetime.date):
            return datetime.datetime.combine(d, datetime.time(0, 0, 0))
        elif isinstance(d, six.string_types):
            d = d.strip()

            if self.null_values in d.lower():
                return None
        else:
            raise CastError('Can not parse value "%s" as datetime.' % d)

        if self.datetime_format:
            try:
                return datetime.datetime.strptime(d, self.datetime_format)
            except:
                raise CastError('Value "%s" does not match date format.' % d)

        value, ctx = self._parser.parseDT(
            d,
            sourceTime=self._source_time,
            tzinfo=self.timezone
        )

        if ctx.hasDate and ctx.hasTime:
            return value
        elif ctx.hasDate and not ctx.hasTime:
            return datetime.datetime.combine(value.date(), datetime.time.min)

        try:
            dt = isodate.parse_datetime(d)

            return dt
        except:
            pass

        raise CastError('Can not parse value "%s" as datetime.' % d)
dataset/ETHPy150Open wireservice/agate/agate/data_types/date_time.py/DateTime.cast/swapped operands of `in`