Skip to content

Instantly share code, notes, and snippets.

{"nbformat_minor": 0, "cells": [{"execution_count": 1, "cell_type": "code", "source": "%pylab inline\nimport pandas as pd\nimport statsmodels.api as sm\nimport pylab as pl\nimport numpy as np", "outputs": [{"output_type": "stream", "name": "stdout", "text": "Populating the interactive namespace from numpy and matplotlib\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"execution_count": 2, "cell_type": "code", "source": "df = pd.read_csv(r'C:\\Users\\mburke05\\Desktop\\Flexshopper\\Mercury_OrderDetail_01-05-2015_001.csv', parse_dates = {'parsed_date' : [1, 2]})", "outputs": [{"output_type": "stream", "name": "stderr", "text": "C:\\Users\\mburke05\\Anaconda64\\lib\\site-packages\\pandas\\io\\parsers.py:1159: DtypeWarning: Columns (79,80) have mixed types. Specify dtype option on import or set low_memory=False.\n data = self._reader.read(nrows)\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"execution_count": 3, "cell_type": "code", "source": "# eliminate columns that are either redundant
{"nbformat_minor": 0, "cells": [], "nbformat": 4, "metadata": {}}
{"nbformat_minor": 0, "cells": [], "nbformat": 4, "metadata": {}}
{
"cells": [
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
{"nbformat_minor": 0, "cells": [{"execution_count": 94, "cell_type": "code", "source": "%pylab inline\nimport pandas as pd\nimport statsmodels.api as sm\nimport pylab as pl\nimport numpy as np\nimport matplotlib.patches as mpatches", "outputs": [{"output_type": "stream", "name": "stdout", "text": "Populating the interactive namespace from numpy and matplotlib\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"execution_count": 2, "cell_type": "code", "source": "df = pd.read_csv(r'C:\\Users\\mburke05\\Desktop\\Flexshopper\\Mercury_OrderDetail_01-05-2015_001.csv', parse_dates = {'parsed_date' : [1, 2]})", "outputs": [{"output_type": "stream", "name": "stderr", "text": "C:\\Users\\mburke05\\Anaconda64\\lib\\site-packages\\pandas\\io\\parsers.py:1159: DtypeWarning: Columns (79,80) have mixed types. Specify dtype option on import or set low_memory=False.\n data = self._reader.read(nrows)\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"execution_count": 3, "cell_type": "code", "source": "# eli
{
"cells": [
{
"cell_type": "code",
"execution_count": 227,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
{
"cells": [
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
from math import floor, sqrt
def find_next_prime(n):
""" We use is_prime passed through a while loop to check if a given value (starting at n+1) is_prime
and exit if we've found our number. I think this too can be accomplished potentially using itertools to
greater effect and would love to hear criticism. I know that while True conditionals are generally frowned upon
in python."""
i = n+1
while True:
if is_prime(i):
import unittest
NUMB = str(731671765313306249192251196744265747423553491949349698352031277450632623957831801698480186947885184385861560789112949495459501737958331952853208805511125406987471585238630507156932909632952274430435576689664895044524452316173185640309871112172238311362229893423380308135336276614282806444486645238749303589072962904915604407723907138105158593079608667017242712188399879790879227492190169972088809377665727333001053367881220235421809751254540594752243525849077116705560136048395864467063244157221553975369781797784617406495514929086256932197846862248283972241375657056057490261407972968652414535100474821663704844031998900088952434506585412275886668811642717147992444292823086346567481391912316282458617866458359124566529476545682848912883142607690042242190226710556263211111093705442175069416589604080719840385096245544436298123098787992724428490918884580156166097919133875499200524063689912560717606058861164671094050775410022569831552000559357297257163626956188267042825248360082325753042075296
import unittest
test_string = ["spare", "hello", "pears", "world", "reaps"]
def find_anagrams(strings, word):
"""Takes a list of strings as an argument and returns a list of strings that are anagrams of
the provided word like so:
find_anagrams(["spare", "hello", "pears", "world", "reaps"], "parse") = ["spare", "pears", "reaps"]
"""
return [string for string in strings if sorted(string) == sorted(word)]