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)
import networkx as nx | |
import numpy as np | |
from nltk.tokenize.punkt import PunktSentenceTokenizer | |
from sklearn.feature_extraction.text import TfidfTransformer, CountVectorizer | |
def textrank(document): | |
sentence_tokenizer = PunktSentenceTokenizer() | |
sentences = sentence_tokenizer.tokenize(document) | |
import sys | |
import subprocess | |
def copy(s): | |
if sys.platform == 'win32' or sys.platform == 'cygwin': | |
subprocess.Popen(['clip'], stdin=subprocess.PIPE).communicate(s) | |
else: | |
raise Exception('Platform not supported') | |
''' |
<# | |
.SYNOPSIS | |
Adds an XML fragment to an XmlNode | |
.DESCRIPTION | |
Adds an XML fragment to an XmlNode | |
.NOTES | |
Author : Thomas Freudenberg - info@thomasfreudenberg.com | |
/* Drop all non-system stored procs */ | |
DECLARE @name VARCHAR(128) | |
DECLARE @SQL VARCHAR(254) | |
SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] = 'P' AND category = 0 ORDER BY [name]) | |
WHILE @name is not null | |
BEGIN | |
SELECT @SQL = 'DROP PROCEDURE [dbo].[' + RTRIM(@name) +']' | |
EXEC (@SQL) |
""" | |
Usage: python remove_output.py notebook.ipynb [ > without_output.ipynb ] | |
Modified from remove_output by Minrk | |
""" | |
import sys | |
import io | |
import os | |
from IPython.nbformat.current import read, write |
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)
# (C) Mathieu Blondel, November 2013 | |
# License: BSD 3 clause | |
import numpy as np | |
def ranking_precision_score(y_true, y_score, k=10): | |
"""Precision at rank k | |
Parameters |
/* Exercise: Loops and Functions #43 */ | |
package main | |
import ( | |
"fmt" | |
"math" | |
) | |
func Sqrt(x float64) float64 { | |
z := float64(2.) |