A personal diary of DataFrame munging over the years.
Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)
| from django.db import connection | |
| from django.conf import settings | |
| cursor = connection.cursor() | |
| cursor.execute('SHOW TABLES') | |
| results=[] | |
| for row in cursor.fetchall(): | |
| results.append(row) | |
| for row in results: | |
| cursor.execute('ALTER TABLE %s CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;' % (row[0])) |
A personal diary of DataFrame munging over the years.
Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)
| __author__ = 'leonmax' | |
| import asyncio | |
| from asyncio import (coroutine, subprocess) | |
| import sys | |
| import logging | |
| FORMAT = '%(asctime)s - %(name)s - %(levelname)s - %(message)s' | |
| logging.basicConfig(level=logging.INFO, format=FORMAT) |
| """ | |
| Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy) | |
| BSD License | |
| """ | |
| import numpy as np | |
| # data I/O | |
| data = open('input.txt', 'r').read() # should be simple plain text file | |
| chars = list(set(data)) | |
| data_size, vocab_size = len(data), len(chars) |
| """ | |
| Vanilla Char-RNN using TensorFlow by Vinh Khuc (@knvinh). | |
| Adapted from Karpathy's min-char-rnn.py | |
| https://gist.github.com/karpathy/d4dee566867f8291f086 | |
| Requires tensorflow>=1.0 | |
| BSD License | |
| """ | |
| import random | |
| import numpy as np | |
| import tensorflow as tf |
| from selenium import webdriver | |
| from selenium.webdriver.common.action_chains import ActionChains | |
| def enter_hours(self, cell, amount): | |
| #Double-click | |
| actions = ActionChains(self.driver) | |
| actions.move_to_element(cell) | |
| actions.double_click(cell) | |
| actions.perform() | |
| import pandas as pd | |
| import itertools | |
| import time | |
| import multiprocessing | |
| from typing import Callable, Tuple, Union | |
| def groupby_parallel( | |
| groupby_df: pd.core.groupby.DataFrameGroupBy, | |
| func: Callable[[Tuple[str, pd.DataFrame]], Union[pd.DataFrame, pd.Series]], | |
| num_cpus: int = multiprocessing.cpu_count() - 1, |
| package main | |
| import ( | |
| "bufio" | |
| "fmt" | |
| "io" | |
| "os" | |
| "os/exec" | |
| "strings" | |
| ) |
| #!/usr/bin/env bash | |
| catch_kill() { | |
| echo "Caught SIGKILL signal!" | |
| kill -KILL "$pid" 2>/dev/null | |
| } | |
| catch_term() { | |
| echo "Caught SIGTERM signal!" | |
| kill -TERM "$pid" 2>/dev/null |