This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd | |
| def pd_move_regress(X, Y, w, fit_intercept=True): | |
| assert (X.index == Y.index).all() | |
| B, A = move_regress(X.values, Y.values, w, fit_intercept=fit_intercept) | |
| idx = pd.MultiIndex.from_product([X.columns, Y.columns]) | |
| B = pd.DataFrame(B.reshape(len(B), -1), index=X.index, columns=idx) | |
| A = pd.DataFrame(A, index=X.index, columns=Y.columns) | |
| return B, A |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from math import log, pi | |
| import numba | |
| import scipy.optimize as opt | |
| @numba.jit(nopython=True, nogil=True) | |
| def _precompute_dp(x, y): | |
| T = 1.0 * x.shape[0] | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # coding: utf-8 | |
| # In[ ]: | |
| import numpy as np | |
| import pandas as pd | |
| import xarray as xr |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import io | |
| def tf_summary_image(figure): | |
| figure.canvas.draw() | |
| w, h = figure.canvas.get_width_height() | |
| with io.BytesIO() as buffer: | |
| figure.savefig(buffer, format='png') | |
| image_str = buffer.getvalue() | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MergeSequence(keras.utils.Sequence): | |
| def __init__(self, *seqs): | |
| lens = [len(s) for s in seqs] | |
| length = sum(lengths) | |
| indices = np.zeros((length, 2), dtype='int') | |
| for n, i in zip(lens, np.cumsum(lens))[:-1]: | |
| indices[i:] += [1, n] | |
| self.indices = indices |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from collections import defaultdict | |
| import numpy as np | |
| import pandas as pd | |
| import tensorflow as tf | |
| import xarray as xr | |
| tf.enable_eager_execution() | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| import pandas as pd | |
| import xarray as xr | |
| @xr.register_dataarray_accessor('str') | |
| class StringAccessor: | |
| def __init__(self, xarray_obj): | |
| self._obj = xarray_obj | |
| self._data = xarray_obj.data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static class Pandas | |
| { | |
| public static double[] Ewma( | |
| double[] vals, double com, | |
| bool adjust=true, bool ignore_na=false, int minp=0) | |
| { | |
| int N = vals.Length; | |
| var output = new double[N]; | |
| if (N == 0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def diag(A, k=0): | |
| s = slice( | |
| max(k, -A.shape[1] * k), | |
| max(0, (A.shape[1] - k) * A.shape[1]), | |
| A.shape[1] + 1 | |
| ) | |
| return A.ravel()[s] |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.