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)
def multireplace(string, replacements, ignore_case=False): | |
""" | |
Given a string and a replacement map, it returns the replaced string. | |
:param str string: string to execute replacements on | |
:param dict replacements: replacement dictionary {value to find: value to replace} | |
:param bool ignore_case: whether the match should be case insensitive | |
:rtype: str | |
""" |
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)
#!/usr/bin/env python | |
import multiprocessing | |
import random | |
import time | |
class Logger: | |
def __init__(self, num_lines, last_output_per_process, terminal_lock): | |
self.num_lines = num_lines |
docker ps | awk {' print $1 '} | tail -n+2 > tmp.txt; for line in $(cat tmp.txt); do docker kill $line; done; rm tmp.txt |
refer to: https://stackoverflow.com/questions/39371772/how-to-install-anaconda-on-raspberry-pi-3-model-b
{USER}: pi
Install Miniconda 3:
wget http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-armv7l.sh
sudo md5sum Miniconda3-latest-Linux-armv7l.sh # (optional) check md5
sudo /bin/bash Miniconda3-latest-Linux-armv7l.sh # -> change default directory to /home/pi/miniconda3
#coding:utf-8 | |
import psutil | |
from mpl_toolkits.mplot3d import Axes3D | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import matplotlib.animation as animation | |
TIME_NUM = 90 | |
FRAMES = 360 |
import string | |
import nltk | |
from nltk.tokenize import RegexpTokenizer | |
from nltk.corpus import stopwords | |
import re | |
def preprocess(sentence): | |
sentence = sentence.lower() | |
tokenizer = RegexpTokenizer(r'\w+') | |
tokens = tokenizer.tokenize(sentence) |
from collections import OrderedDict | |
import numpy as np | |
import spacy | |
from spacy.lang.en.stop_words import STOP_WORDS | |
nlp = spacy.load('en_core_web_sm') | |
class TextRank4Keyword(): | |
"""Extract keywords from text""" | |
#!/bin/bash | |
# | |
#This script assumes very little other than a fresh Ubuntu install (using the Windows store) on Win10 1709 or newer with WSL installed already | |
#In Powershell, run the following to install WSL and Ubuntu | |
# | |
#Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux | |
#Invoke-WebRequest -Uri https://aka.ms/wsl-ubuntu-1604 -OutFile ~/Ubuntu.zip -UseBasicParsing | |
#Expand-Archive ~/Ubuntu.zip ~/Ubuntu | |
#~/Ubuntu/ubuntu.exe | |
# |