Skip to content

Instantly share code, notes, and snippets.

@somiandras
somiandras / pandas_pipe_logger.py
Created April 4, 2019 12:25
Logging function to be used in pd.DataFrame.pipe().
def pipe_log(data, logger, message=None, level='DEBUG'):
'''
Logging function to be used in pd.DataFrame.pipe(). Insert anywhere
in a method chain to log head and shape of dataframe/series along
with a custom message with the set logging level, then returns the
dataframe unchanged.
Params:
- data: pandas.DataFrame or pandas.Series
@somiandras
somiandras / original.js
Last active November 7, 2016 17:27
Map and reduce instead of entangled 'for..each' and 'if...else' blocks.
function extractData(messages) {
let data = {};
messages.forEach(message => {
if (message.symbols) {
let symbols = message.symbols;
symbols.forEach(symbol => {
if (data[symbol.symbol]) {
data[symbol.symbol].count += 1;
} else {
data[symbol.symbol] = {
@somiandras
somiandras / index.html
Last active October 28, 2016 13:32
Bubble (pack) chart for Stocktwits stock mentions.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>D3 test</title>
<style>
body {
font-family: Arial;
color: #888888;
}