This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xhtml = "<h1 align='center'>Test print</h1>\n" | |
xhtml += "<h2>This is printed from within a Python application</h2>\n" | |
xhtml += "<p style=\"color:red;\">Coloured red using css</p>\n" | |
xhtml | |
from xhtml2pdf import pisa | |
ls | |
filename = "simplePrint.pdf" | |
pdf = pisa.CreatePDF(xhtml, file(filename, "w")) | |
ls | |
pdf = pisa.CreatePDF(xhtml.encode('utf-8, file(filename, "w")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
s = df['A'] | |
s | |
data['username'] | |
data.T['username'] | |
data = data.T | |
data | |
data[7] | |
data['username'] | |
data['username']['darlene'] | |
data['username'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tweepy | |
import os | |
os.environ.get('TWITTER_ACCESS_TOKEN') | |
os.environ.get('TWITTER_ACCESS_SECRET') | |
consumer_secret = os.environ.get('TWITTER_SECRET') | |
consumer_key = os.environ.get('TWITTER_KEY') | |
access_token = os.environ.get('TWITTER_ACCESS_TOKEN') | |
access_token_secret = os.environ.get('TWITTER_ACCESS_SECRET') | |
auth = tweepy.OAuthHandler(consumer_key, consumer_secret) | |
auth.set_access_token(access_token, access_token_secret) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from numpy import matrix | |
matrix('1908 January 4.5 -5.6') | |
matrix("1908 'January' 4.5 -5.6") | |
matrix([4.5 -5.6],[2, 4]) | |
matrix([[4.5 -5.6],[2, 4]]) | |
matrix([[4.5 5.6],[2, 4]]) | |
matrix([[4.5, -5.6],[2, 4]]) | |
matrix([4.5, -5.6],[2, 4]) | |
matrix([[4.5, -5.6],[2, 4]]) | |
matrix([[4.5, -5.6],[2, 4]], header=['ss','b']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
reader = csv.reader(open('1.csv', 'rb'), delimiter=',', quotechar='"') | |
d = {} | |
for row in reader: | |
d[row[0]] = row[1] | |
temp_list1 = d.keys() | |
set(temp_list1) & set(temp_list2) | |
common_Hz = set(temp_list1) & set(temp_list2) | |
for fq in common_Hz: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
data = json.loads(open('_User.json','rb').read()) | |
data | |
data['results'][0] | |
data['results'][23] | |
name = 'fc336b02-47e5-4a11-ba38-59e60da3dfe7-yusuf done.png" | |
name = 'fc336b02-47e5-4a11-ba38-59e60da3dfe7-yusuf done.png' | |
name.split() | |
'%20'.join(name.split()) | |
data['results'][0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
data = json.loads('_User.json','rb') | |
data = json.load('_User.json','rb') | |
data = json.load(open('_User.json','rb').read()) | |
data = json.loads(open('_User.json','rb').read()) | |
data | |
ls | |
data['results'].keys() | |
data['results'] | |
data['results'][0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image | |
fi = Image.open('f23bf11c-aa22-419b-855b-ab0b9f1f5cb3-SRV_0122.jpg') | |
fi.size() | |
fi.size | |
fi = Image.open('bd654b14-87a5-4ff3-868f-bd72b5121c49-IMG_9941.jpg') | |
fi.size | |
5184.0/3456 | |
3456.0/5184 | |
float(1024*3456) / 5184 | |
fi.resize((1024,683), Image.ANTIALIAS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
filenames = os.listdir('./_User_sharded/') | |
f = open('mongo_upload','wb') | |
f.write('#!/bin/bash\n') | |
f.write('cd ./_User_sharded/\n') | |
for filename in filenames: | |
cmd = ['mongoimport','--db','takezero_raw','--collection','users','--file',filename] | |
f.write(' '.join(cmd) + "\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f = open('_User.json','rb') | |
import json | |
data = json.loads(f.read()) | |
f.close() | |
data | |
data[0] | |
data.keys() | |
data['results'][0] | |
data['results'][0].keys() | |
from pyes import * |
NewerOlder