Skip to content

Instantly share code, notes, and snippets.

@chris-b1
chris-b1 / ffill.jl
Last active May 27, 2020 12:37
DataFrames.jl forward fill
ffill(a::AbstractArray) = copy(a)
function ffill(a::AbstractArray{Union{Missing, T}}) where {T}
res = similar(a, T)
if ismissing(first(a))
error("first value in array is missing")
else
fillval::T = first(a)
end
for i in eachindex(a)
%%cython
cimport numpy as cnp
import numpy as np
cimport cython
cdef extern from "numpy/npy_math.h":
bint npy_isnan(double x) nogil
cdef inline bint isnan(double x) nogil:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
struct Array {
int len;
double* values;
};
static inline void add_var(double val, double *nobs, double *mean_x, double *ssqdm_x) {
; msvc 2015 - works!
000000018005E4D7: E8 84 2B FA FF call printf
000000018005E4DC: 48 8B 85 18 01 00 mov rax,qword ptr [rbp+118h]
00
000000018005E4E3: F2 0F 10 04 03 movsd xmm0,mmword ptr [rbx+rax]
000000018005E4E8: 66 0F 2E C0 ucomisd xmm0,xmm0
000000018005E4EC: 7A 34 jp 000000018005E522
000000018005E4EE: 75 32 jne 000000018005E522
000000018005E4F0: F2 0F 5C C7 subsd xmm0,xmm7
000000018005E4F4: F2 41 0F 58 F2 addsd xmm6,xmm10
; MSVC 2017
000000018005C898: E8 C3 47 FA FF call printf
000000018005C89D: 48 8B 85 18 01 00 mov rax,qword ptr [rbp+118h]
00
000000018005C8A4: 4C 8D 4C 24 78 lea r9,[rsp+78h]
000000018005C8A9: 4C 8D 45 98 lea r8,[rbp-68h]
000000018005C8AD: 48 8D 54 24 70 lea rdx,[rsp+70h]
000000018005C8B2: F2 0F 10 04 07 movsd xmm0,mmword ptr [rdi+rax]
000000018005C8B7: E8 34 0A 00 00 call 000000018005D2F0
000000018005C8BC: 48 8D 0D 6D 1F 01 lea rcx,[18006E830h]
This file has been truncated, but you can view the full file.
/* Generated by Cython 0.28.3 */
#define PY_SSIZE_T_CLEAN
#include "Python.h"
#ifndef Py_PYTHON_H
#error Python headers needed to compile C extensions, please install development version of Python.
#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
#error Cython requires Python 2.6+ or Python 3.3+.
#else
#define CYTHON_ABI "0_28_3"
#include <iostream>
#include <string>
#include <vector>
#include <chrono>
#include "xlnt/xlnt.hpp"
#include "xlnt/workbook/streaming_workbook_reader.hpp"
int main()
{
import pandas as pd
import numpy as np
from pyarrow.parquet import read_pandas, write_table
from pyarrow import Table
import timeit
N = 25000
s = np.array(['AAAAAAAA', 'BBBBBBB', 'CCCCCCCC'], dtype='O')
#include <numeric>
#include <vector>
#include <iostream>
#include <string>
#include <random>
#include <chrono>
#include <algorithm>
#include <cstdint>
#include <cmath>
from collections import OrderedDict
from itertools import chain
import numba
import xarray as xr
from xarray.core.computation import UFuncSignature
def _map_sig(sig, dim_map):
return [tuple(dim_map[x] for x in t)
for t in sig]