Skip to content

Instantly share code, notes, and snippets.

View grantmwilliams's full-sized avatar

Grant Williams grantmwilliams

View GitHub Profile
@grantmwilliams
grantmwilliams / df_plot_example.ipynb
Created March 25, 2022 18:41
Example showing common plotting problems with bar charts in pandas data frames
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@grantmwilliams
grantmwilliams / example.py
Created January 28, 2022 17:02
Pyarrow uint32() -> int64() bug?
import pyarrow as pa
import pyarrow.parquet as pq
file_name_mapping = {
pa.int32(): "int32",
pa.uint32(): "uint32",
pa.int64(): "int64",
pa.uint64(): "uint64"
}
@grantmwilliams
grantmwilliams / iter_parquet.py
Created June 27, 2021 12:45
Pyarrow iter_batches as python native iterable
import s3fs
import pyarrow as pa
import pyarrow.parquet as pq
from itertools import chain
from typing import Tuple, Any
def iter_parquet(s3_uri: str, columns = None, batch_size=1_000) -> Tuple[Any]:
""" This file uses a decision tree to classify the input data
and then loads the appropriate auxiliary dataset from the classification result
Uses SKlearn's decision tree implementation and as an example the
SKlearn iris dataset
"""
import sys
import numpy as np # only used to create our example datasets.
import pandas as pd # only used to create our example datasets.
from sklearn.datasets import load_iris
-module(solution).
-export([main/0]).
% 1. If contains a "0" return DEAD
% 2. Use Deterministic Miller-Rabin Primality To Check Primality
% 3. If stripping from Left and Right gives primes return "CENTRAL"
% 4. Else If stripping from Left gives primes return "LEFT"
% 5. Else If stripping from Right gives primes return "RIGHT"
% 6. Else Return "DEAD"
#include <iostream>
#include <vector>
#include <cmath> // std::sqrt
#include <algorithm> // std::fill
#include <chrono>
// implementation of sieve of eratosthenes.
long get_primes(const unsigned long limit)
{
int count_lim = 10001;
arr[10001] = {0}
count = 1;
arr[0] = 2;
num = 2;
bool is_prime;
while (count < 10001) // loop through all numbers
{
num++; // starts with 3
is_prime = true; // sets the number to prime unless we find otherwise
std::vector<int> get_primes(int limit)
{
std::vector<char> primes(limit + 1, 1);
std::vector<int> final;
// 0 and 1 are nonprime by definition
primes[0] = 0; primes[1] = 0;
for (int i = 2; i * i <= limit; i++)
{
std::vector<int> get_primes(int limit)
{
std::vector<char> primes(limit, 1);
std::vector<int> final;
// 0 and 1 are nonprime by definition
primes[0] = 0; primes[1] = 0;
for (int i = 2; i * i <= limit; i++)
{
// fib_method.cpp -- Grant Williams \\
#include <stdio.h>
#include <fstream>
#include <math.h>
using namespace std;
//Uses matrix operations \\
void multiply(int F[2][2], int M[2][2]);