Skip to content

Instantly share code, notes, and snippets.

View tathagata's full-sized avatar
🐢
debugging

Tathagata tathagata

🐢
debugging
View GitHub Profile
# coding: utf-8
# ## Data Analysis using Pandas
# Pandas has become the defacto package for data analysis. In this workshop, we are going to use the basics of pandas to analyze the interests of today's group. We are going to use meetup.com's api and fetch the list of interests that are listed in each of our meetup.com profile. We will compute which interests are common, which are uncommon, and find out how we can use topics of common interest to form teams for project night.
#
# Lets get started by importing the essentials. You would need meetup.com's python api and pandas installed.
# In[ ]:
@tathagata
tathagata / startup.py
Created November 16, 2017 00:57
November 2017 Project Night
!pip install meetup-api
import meetup.api
import pandas as pd
print("See you at project night!")
@tathagata
tathagata / varargs.py
Created March 1, 2014 12:15
var args in python
def square(*l): print map(lamda x:x*x, l)
>>> square(1,2,3)
[1, 4, 9]
>>> square([1,2,3])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 1, in f
File "<stdin>", line 1, in <lambda>
TypeError: can't multiply sequence by non-int of type 'list'
>>> f(1)
select count(*)/3573.0*100.0from HospitalsOnTwitter h, survey_names s where h.organization=s.name;
8.22837951301427
from twython import Twython, TwythonAuthError, TwythonError
from pprint import pprint
import json, time
import sqlite3, mysql.connector as sql
def connect():
db_params = {
'user' : "",
'password' : "",
'host' : "192.168.1.106",
C:\Program Files (x86)\MySQL\MySQL Workbench 5.2 CE\utilities&gt;mysql.exe --defaults-extra-file="c:\users\tathag~1\appdata\local\temp\tmpcwv283.cnf" --host=localhost --user=root --password --port=3306 --default-character-set=latin2 --comments --database=multiwordnet &lt; "C:\\Users\\Tathagata\\projects\\NewTracelabData\\EX3\\cyptichash\\MWN_1.5.0\\italian_index.sql"
Could not open required defaults file: c:\users\tathag~1\appdata\local\temp\tmpcwv283.cnf
Fatal error in defaults handling. Program aborted
Enter password: ********
@tathagata
tathagata / chardet-detect-string.py
Created June 24, 2013 18:50
Detection using chardet
>>>import chardet
>>>chardet.detect("ombrosità")
{'confidence': 0.8444448197532533, 'encoding': 'ISO-8859-2'}
>>>chardet.detect("bebè")
{'confidence': 0.63333361481494, 'encoding': 'ISO-8859-2'}
Running: mysql.exe --defaults-extra-file="c:\users\tathag~1\appdata\local\temp\tmp531z_l.cnf" --host=localhost --user=root --port=3306 **--default-character-set=utf8** --comments --database=multiwordnet &lt; "C:\\Users\\Tathagata\\projects\\NewTracelabData\\EX3\\cryptichash\\MWN_1.5.0\\italian_index.sql"
@tathagata
tathagata / MySQL-import.py
Created June 24, 2013 18:47
MySQL default encoding import problems
ERROR 1062 (23000) at line 3053: Duplicate entry 'bebé' for key 'PRIMARY
INSERT INTO italian_index VALUES ('bebè','n#07094006',NULL,NULL,NULL);
INSERT INTO italian_index VALUES ('bebé','n#07094006',NULL,NULL,NULL);