Parses string values into datetime.

        Args:
            col(pandas.DataFrame): Data to transform.

        Returns:
            pandas.Series
189596
def safe_datetime_cast(self, col):
        
        casted_dates = pd.to_datetime(col[self.col_name], format=self.date_format, errors='coerce')

        if len(casted_dates[casted_dates.isnull()]):
            # This will raise an error for bad formatted data
            # but not for out of bonds or missing dates.
            slice_ = casted_dates.isnull() & ~col[self.col_name].isnull()
            col[slice_][self.col_name].apply(self.strptime_format)

        return casted_dates
1351465
def to_date_or_datetime(value, ctx):
    
    if isinstance(value, str):
        temporal = ctx.get_date_parser().auto(value)
        if temporal is not None:
            return temporal
    elif type(value) == datetime.date:
        return value
    elif isinstance(value, datetime.datetime):
        return value.astimezone(ctx.timezone)

    raise EvaluationError("Can't convert '%s' to a date or datetime" % str(value))
313698
def date_string_to_date(p_date):
    
    result = None

    if p_date:
        parsed_date = re.match(r'(\d{4})-(\d{2})-(\d{2})', p_date)
        if parsed_date:
            result = date(
                int(parsed_date.group(1)),  # year
                int(parsed_date.group(2)),  # month
                int(parsed_date.group(3))   # day
            )
        else:
            raise ValueError

    return result
281883
def parse_datetime(value):
    
    if not value:
        return None
    elif isinstance(value, datetime.datetime):
        return value
    return dateutil.parser.parse(value)
1280076
def proto_ts_from_datetime_str(dt):
    

    ts = Timestamp()
    if (dt is not None):
        try:
            ts.FromJsonString(dt)
        except ParseError:
            pass
    return ts
1272784
def get(self, col_str):
        '''
        

        '''
        data_column=zeros(self.ilines)
        for i in range(self.ilines):
            data_column[i]=self.data[i][self.col_num[col_str]]
        return data_column
182998
def timeseries(self, dataframe=False):
        

        self.query.by_period()
        ts = super().timeseries(dataframe=dataframe)
        ts['value'] = ts['value'].apply(lambda x: float("%.2f" % x))
        return ts
700394
def str_to_date(date: str) -> datetime.datetime:
    
    date = date.split('.')
    date.reverse()
    y, m, d = date
    return datetime.datetime(int(y), int(m), int(d))
399668
def string_to_datetime(self, obj):
        
        if isinstance(obj, six.string_types) and len(obj) == 19:
            try:
                return datetime.strptime(obj, "%Y-%m-%dT%H:%M:%S")
            except ValueError:
                pass
        if isinstance(obj, six.string_types) and len(obj) > 19:
            try:
                return datetime.strptime(obj, "%Y-%m-%dT%H:%M:%S.%f")
            except ValueError:
                pass
        if isinstance(obj, six.string_types) and len(obj) == 10:
            try:
                return datetime.strptime(obj, "%Y-%m-%d")
            except ValueError:
                pass
        return obj
1270735
def to_datetime(self, column):
        '''
        
        '''
        if column in self:
            if self[column].dtype in NUMPY_NUMERICAL:
                self[column] = pd.to_datetime(self[column], unit='s')
            else:
                self[column] = pd.to_datetime(self[column], utc=True)
75691
def process_row(cls, data, column_map):
        """"""
        row = {}
        for key,value in data.iteritems():
            if not value:
                value = '-'                
            elif isinstance(value, list):
                value = value[1]
            elif isinstance(value, dict):
                if 'type_name' in value:
                    if 'UnixTimeStamp' in value['type_name']:
                        value = datetime.datetime.utcfromtimestamp(value['epoch'])
                        if value == datetime.datetime(1970, 1, 1, 0, 0):
                            value = '-'

            # Assume the value is somehow well formed when we get here
            row[column_map[key]] = value
        return row
1254793
def cast_datetime_filter(value):
    
    if isinstance(value, str):
        dtime = parse_datetime(value)

    elif isinstance(value, datetime):
        dtime = value
    else:
        raise ValueError('Received value of type {0}'.format(type(value)))

    return dtime.isoformat()
1126677
def convert(input, type):
        
        try:
            if not input:
                if type == Types.TYPE_STRING:
                    return ''
                else:
                    return None
            if type == Types.TYPE_STRING:
                if isinstance(input, datetime.date):
                    return input.strftime('%Y-%m-%d')
                else:
                    return input
            if type == Types.TYPE_FLOAT:
                return float(input)
            elif type == Types.TYPE_INT:
                return int(input)
            elif type == Types.TYPE_DATE:
                if isinstance(input, datetime.date):
                    return input
                else:
                    return datetime.datetime.strptime(input[0:10], '%Y-%m-%d')
            elif type == Types.TYPE_DATETIME:
                if isinstance(input, datetime.datetime):
                    return input
                else:
                    return datetime.datetime.strptime(input[0:19], '%Y-%m-%dT%H:%M:%S') # 2017-10-01T10:01:00.479+0300
            else:
                return NotImplementedError('Not supported type - {}'.format(type))
        except Exception as e:
            logging.error(e, exc_info=True)
            raise Exception(e)
523891
def parse_date(date_str: str, pattern=_RE_DATE) -> dt.date:
    """"""

    groups = re.match(pattern, date_str)

    return dt.date(*_date_to_tuple(groups.groupdict()))
999753
def reverse_transform(self, col):
        
        if isinstance(col, pd.Series):
            col = col.to_frame()

        output = pd.DataFrame(index=col.index)
        output[self.col_name] = col.apply(self.safe_date, axis=1)

        return output
1340455
def string_to_date(value):
    
    if isinstance(value, datetime.date):
        return value

    return dateutil.parser.parse(value).date()
808063
def safe_date(self, x):
        

        t = x[self.col_name]
        if np.isnan(t):
            return t

        elif np.isposinf(t):
            t = sys.maxsize

        elif np.isneginf(t):
            t = -sys.maxsize

        tmp = time.localtime(float(t) / 1e9)
        return time.strftime(self.date_format, tmp)