Formatting series or timeseries columns to int and checking validity.
    If `index=False`, the function works on the `pd.Series x`; else,
    the function casts the index of `x` to int and returns x with a new index.
191848
def to_int(x, index=False):
    
    _x = x.index if index else x
    cols = list(map(int, _x))
    error = _x[cols != _x]
    if not error.empty:
        raise ValueError('invalid values `{}`'.format(list(error)))
    if index:
        x.index = cols
        return x
    else:
        return _x
954385
def get_X0(X):
    
    if pandas_available and isinstance(X, pd.DataFrame):
        assert len(X) == 1
        x = np.array(X.iloc[0])
    else:
        x, = X
    return x
729563
def _try_pydatetime(x):
    
    try:
        # for datetimeindex
        x = [y.isoformat() for y in x.to_pydatetime()]
    except AttributeError:
        pass
    try:
        # for generic series
        x = [y.isoformat() for y in x.dt.to_pydatetime()]
    except AttributeError:
        pass
    return x
1066733
def _set_TS_index(self, data):
        
        
        # Set index
        data.index = pd.to_datetime(data.index, error= "ignore")

        # Format types to numeric
        for col in data.columns:
            data[col] = pd.to_numeric(data[col], errors="coerce")

        return data
306737
def var(series):
    
    if np.issubdtype(series.dtype, np.number):
        return series.var()
    else:
        return np.nan
483460
def get_column(self, X, column):
        
        if isinstance(X, pd.DataFrame):
            return X[column].values

        return X[:, column]
77661
function _toNaturalIndex (idx, len) {
    idx = _toInteger(idx);

    return idx >= -len && idx < len ? idx < 0 ? idx + len : idx : NaN;
}
687817
def as_indexable(array):
    
    if isinstance(array, ExplicitlyIndexed):
        return array
    if isinstance(array, np.ndarray):
        return NumpyIndexingAdapter(array)
    if isinstance(array, pd.Index):
        return PandasIndexAdapter(array)
    if isinstance(array, dask_array_type):
        return DaskIndexingAdapter(array)
    raise TypeError('Invalid array type: {}'.format(type(array)))
266585
def _is_valid_index(self, index):
        
        if isinstance(index, int):
            return (index >= 0) and (index < len(self))
        if isinstance(index, list):
            valid = True
            for i in index:
                valid = valid or self._is_valid_index(i)
            return valid
        return False
1338702
def x_values_ref(self, series):
        
        top_row = self.series_table_row_offset(series) + 2
        bottom_row = top_row + len(series) - 1
        return "Sheet1!$A$%d:$A$%d" % (top_row, bottom_row)
797296
def _cast_output_to_type(value, typ):
    ''''''
    if typ == 'b':
        return bool(value)
    if typ == 'i':
        return int(value)
    return value
663657
def from_series(cls, series, offset=0):
        
        return cls(data=series.data, index=series.index, data_name=series.data_name, index_name=series.index_name,
                   sort=series.sort, offset=offset)
838816
def to_python_index(self, length, check_bounds=True, circular=False):
        
        if not self.is_unitless:
            raise ValueError("Index cannot have units: {0!r}".format(self))

        ret = int(self.value)
        if ret != self.value:
            raise ValueError("Index must be an integer: {0!r}".format(ret))

        if ret == 0:
            raise ValueError("Index cannot be zero")

        if check_bounds and not circular and abs(ret) > length:
            raise ValueError("Index {0!r} out of bounds for length {1}".format(ret, length))

        if ret > 0:
            ret -= 1

        if circular:
            ret = ret % length

        return ret
703224
def _sumSeries(a: float, b: float, steps: int) -> float:
        
        return a * (exp(b * steps) - 1) / (exp(b) - 1)
1183962
def __int(value):
    ''''''
    valid, _value = False, value
    try:
        _value = int(value)
        valid = True
    except ValueError:
        pass
    return (valid, _value, 'integer')
451329
def _cast_to_type(self, value):
        
        try:
            return int(value)
        except (ValueError, TypeError):
            self.fail('invalid', value=value)
190627
def _get_value_type(self, other):
        
        if self.values:
            return type(self.values[0])
        elif isinstance(other, TimeSeries) and other.values:
            return type(other.values[0])
        else:
            raise ValueError('Cannot perform arithmetic on empty time series.')