python - Pandas with Decimal? -
i'm calculating standard deviations giving floatingpointerrors. wanted try converting data series decimal (using https://docs.python.org/3/library/decimal.html), see if fixes issue.
i can't seem make pandas series of decimal
.
how can take normal pd.series
of float64
, convert pd.series
of decimal
, such can do:
series.pct_change().ewm(span=35, min_periods=35).std()
would work?
def column_round(decimals): return partial(series.round, decimals=decimals) df.apply(column_round(2))
alternatively lets use np.vectorize
can use decimal.quantize
function rounding, leave variable decimal instead of np.float64
npquantize = np.vectorize(decimal.decimal.quantize)
i have been looking , seems solve issue pct_change
ts.diff().div(ts.shift(1))
Comments
Post a Comment