Skip to content

Instantly share code, notes, and snippets.

View gnurio's full-sized avatar

George Nurijanian gnurio

View GitHub Profile
@gnurio
gnurio / convert_archive.py
Created February 16, 2025 20:16 — forked from deepfates/convert_archive.py
Convert your twitter archive into a training dataset and markdown files
import argparse
import json
import logging
import os
import re
import shutil
from concurrent.futures import ProcessPoolExecutor, as_completed
from dataclasses import dataclass
from datetime import datetime
from typing import Any, Callable, Dict, List, Literal, Optional, Tuple
@gnurio
gnurio / decode_encode_onehot
Created February 22, 2018 22:49
Re-coding a categorical field into one-hot vectors
import pandas as pd
from sklearn.preprocessing import LabelEncoder,OneHotEncoder
def decode_encode(colname):
'''
(str) -> (DataFrame)
Returns a Data Frame with the column given to it transformed into a One-hot encoded set of columns
@gnurio
gnurio / gist:c3bd6d5fa9d67880014e5660df1368f8
Created March 21, 2017 23:43
How to calculate the mode for different categories in a DataFrame
import pandas as pd
from scipy.stats import mode
grouped_mod = df.pivot_table(values='The metric you need the mode for',columns='Category',aggfunc=mode)